Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Show Entire Image as Background Without Cropping

I'm trying to setup a div with a background image with some text on top of it. The background image needs to stretch the entire width of the viewport, which I've been able to do successfully. This is my CSS:

.intro-header {
  padding-top: 50px; 
  padding-bottom: 50px;
  color: #fff;
  background: url(http://) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

The problem I'm having is that it isn't showing the full height of the image. The image is being cropped at the top and bottom. I want the image to show it's full height and the user needs to be able to scroll down to see more content below the image.

Is there a way I can show the full image without cutting the top and bottom off?

Thanks!

like image 787
Thomas Spade Avatar asked Aug 27 '15 23:08

Thomas Spade


People also ask

How do I make the background image fit my screen CSS?

Using CSS, you can set the background-size property for the image to fit the screen (viewport). The background-size property has a value of cover . It instructs browsers to automatically scale the width and height of a responsive background image to be the same or bigger than the viewport.


1 Answers

Remove the fixed and instead of cover use contain. If you want a specific size though I would define a height in my css.

like image 157
Lucas Santos Avatar answered Nov 03 '22 16:11

Lucas Santos