Login | Register | FAQ
Anonymous

Background image 100% in web page

+ Post a reply

8 posts Page 1 of 1


Background image 100% in web page

by riyaz123 » Wed Aug 13, 2014 12:39 pm

How to fix Background image 100% in web page?
User avatar

riyaz123

  • Posts: 15
  • Joined: Sat Jul 05, 2014 7:57 am

Re: Background image 100% in web page

by nanoverso » Thu Aug 14, 2014 1:04 am

Use CSS to define the body background size to 100%:
body {
background-size: 100% 100%;
}
User avatar

nanoverso

  • Posts: 253
  • Joined: Sat May 10, 2014 12:08 am
  • Location: Brazil
--
Free VST Plugins Download.

Re: Background image 100% in web page

by Farhin Qureshi » Thu Jan 19, 2017 12:19 pm

Hi,

I think you have need to try this code.

Code: Select all
body {
    background-image:url("../images/myImage.jpg");
    background-repeat: no-repeat;
    background-size: 100% 100%;
}
html {
    height: 100%
}


Thanks.
User avatar

Farhin Qureshi

  • Posts: 45
  • Joined: Tue Jan 03, 2017 11:33 am
--
Farhin Qureshi
.NET Developer
http://www.ifourtechnolab.com

Re: Background image 100% in web page

by eh3an2010 » Tue Jan 24, 2017 6:48 am

background-size: cover;
User avatar

eh3an2010

  • Posts: 1
  • Joined: Tue Jan 24, 2017 6:45 am

Re: Background image 100% in web page

by jackmarco » Fri Feb 24, 2017 8:57 am

You need to set the height of html to 100%

body {
background-image:url("../images/myImage.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
}
html {
height: 100%
}
http://jsfiddle.net/8XUjP/
User avatar

jackmarco

  • Posts: 2
  • Joined: Fri Feb 10, 2017 7:48 am

Re: Background image 100% in web page

by jelena » Wed Mar 08, 2017 11:06 am

Here is simple example:

html part of code:

Code: Select all
<div class="bgWrapper">
   <div class="bgInner">
     <h1>Some text over image</h1>
  </div>
</div>


css part of code:

Code: Select all
.bgWrapper{
  width:100%;
  height:200px;
  /* Best practice for full width bg photos */
  background-image:url("https://images.unsplash.com/photo-1467173572719-f14b9fb86e5f?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=b734e103303c5965225682077ee72f86");
  background-size:cover;
  background-position:center center;
  background-repeat:no-repeat;
}

.bgInner{
  width:100%;
  height:100%;
  /* always add transparent background color so text can be visible better. Last number (0.5) is transparency and first color but in rgb */
  background-color:rgba(0,0,0,0.5);
  display:table;
}

h1{
  color:#fff;
  text-align:center;
  display:table-cell;
  vertical-align:middle;
}


You can see the FULL EXAMPLE on jsfiddle that I made ( https://jsfiddle.net/48agcpty/1/ ).
User avatar

jelena

  • Posts: 2
  • Joined: Wed Mar 08, 2017 10:40 am
  • Location: Florida

Re: Background image 100% in web page

by jody70 » Wed Mar 08, 2017 1:01 pm

We can do this purely through CSS thanks to the background-size property now in CSS3. We'll use the html element (better than body as it's always at least the height of the browser window) http://www.generalelectricservice.ir/
User avatar

jody70

  • Posts: 2
  • Joined: Wed Mar 08, 2017 12:53 pm
  • Location: http://seocando.ir/

Re: Background image 100% in web page

by jody70 » Wed May 03, 2017 6:34 am

jody70 wrote:We can do this purely through CSS thanks to the background-size property now in CSS3. We'll use the html element (better than body as it's always at least the height of the browser window) http://www.generalelectricservice.ir/
User avatar

jody70

  • Posts: 2
  • Joined: Wed Mar 08, 2017 12:53 pm
  • Location: http://seocando.ir/


+ Post a reply

Page 1 of 1