How do I make the image 100% on the screen?

Asked

Viewed 4,426 times

-1

I have a website in development.

Then I want it to be on the whole screen, it’s to be a responsive site, I’m using the bootstrap... It only gets full screen if I zoom 150%: Example: https://prnt.sc/fe1fig

If I leave it normal it looks like this: Example: https://prnt.sc/fe1fn6 My screen is Full HD.

The image is 1400 x 767 in size.

The link to my code is this: https://codepen.io/sandsoncosta/pen/XRLvvW

He’s not all formatted up,

but here is the full file link: https://drive.google.com/file/d/0B28SaVWuwZ5kSlZURWlWRlljdjg/view?usp=sharing

My html and css file.

Then like I do to leave it all on the screen?

I hope you help me, thank you.

PS.: I’m studying site responsiveness, starting from the beginning, to run on desktop and mobile...

6 answers

2

Try to use

background-size: cover; 

for the element in question!

  • uuuuhuhuhuhuhu! It worked out! Vlw brother!

  • How nice! :)

  • 3

    Can you explain why this solution solves the question? So others can understand why.

  • Hello, Sergio! I believe there are still other attributes that would solve the situation, such as "auto" and "contain". The "cover" attribute makes the size of the image covering the background as large as possible for the area in question

2


Oh yes I understand, you’re using background.

Try this

#banner {
	width: 100%;
	height: 728px;
	position: relative;
	background-image: url(../img/banner.jpg) no-repeat;
  background-size 100% 100%;
}

So the background image will occupy 100% of the element it is part of. I saw there in the code that Section is with width 100% so this should solve your problem

0

In order for an image to be full-screen you must use the CSS properties. Try to use:

img {
  display :block;
  width : 100%;
}

0

img{
  display :block;
  width : 100%;
}

It didn’t work. I can’t solve this problem. Does it have to do with the size of the image? My screen is 1920... I’m cracking my head!

0

It’s not about the size of the image, it should fill the screen even if it lost quality. See this example :

https://codepen.io/EdySilva/pen/PmMqgV

Bootstrap may be influencing, try to use :

img{
  display:block !important;
  width:100% !important;
}

  • Ah, man! I get it! In this case here’s the thing. My image isn’t on the img tag, it’s inside a Section, inside a div with id. The image is pulled in css, it’s in the code I put in the codepen: https://codepen.io/sandsoncosta/pen/XRLvvW... This is to make a slide between two images. In the image alone she goes normally, Understood now?

0

Do the following.

#banner {
	width: 100%;
	height: 728px;
	position: relative;
	background-image: url(../img/banner.jpg) no-repeat;
  background-size :100% 100%;
}

This will leave the image occupying 100% of width and height of the Section, ie will have the same size of the Section. Simply make Ction take over the screen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.