Anmelden | Registrieren | FAQ
Anonymous

Background image 100% in web page

+ Antwort erstellen

8 Beiträge Seite 1 von 1


Background image 100% in web page

von riyaz123 » Mi Aug 13, 2014 12:39 pm

How to fix Background image 100% in web page?
Benutzeravatar

riyaz123

  • Beiträge: 15
  • Registriert: Sa Jul 05, 2014 7:57 am

Re: Background image 100% in web page

von nanoverso » Do Aug 14, 2014 1:04 am

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

nanoverso

  • Beiträge: 253
  • Registriert: Sa Mai 10, 2014 12:08 am
  • Wohnort: Brazil
--
Mario Blog (Portuguese): https://jogosdomariosuperbros.blogspot.com

Re: Background image 100% in web page

von Farhin Qureshi » Do Jan 19, 2017 12:19 pm

Hi,

I think you have need to try this code.

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


Thanks.
Benutzeravatar

Farhin Qureshi

  • Beiträge: 45
  • Registriert: Di Jan 03, 2017 11:33 am
--
Farhin Qureshi
.NET Developer
http://www.ifourtechnolab.com

Re: Background image 100% in web page

von eh3an2010 » Di Jan 24, 2017 6:48 am

background-size: cover;
Benutzeravatar

eh3an2010

  • Beiträge: 1
  • Registriert: Di Jan 24, 2017 6:45 am

Re: Background image 100% in web page

von jackmarco » Fr 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/
Benutzeravatar

jackmarco

  • Beiträge: 2
  • Registriert: Fr Feb 10, 2017 7:48 am

Re: Background image 100% in web page

von jelena » Mi Mär 08, 2017 11:06 am

Here is simple example:

html part of code:

Code: Alles auswählen
<div class="bgWrapper">
   <div class="bgInner">
     <h1>Some text over image</h1>
  </div>
</div>


css part of code:

Code: Alles auswählen
.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/ ).
Benutzeravatar

jelena

  • Beiträge: 2
  • Registriert: Mi Mär 08, 2017 10:40 am
  • Wohnort: Florida

Re: Background image 100% in web page

von jody70 » Mi Mär 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/
Benutzeravatar

jody70

  • Beiträge: 2
  • Registriert: Mi Mär 08, 2017 12:53 pm
  • Wohnort: http://seocando.ir/

Re: Background image 100% in web page

von jody70 » Mi Mai 03, 2017 6:34 am

jody70 hat geschrieben: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/
Benutzeravatar

jody70

  • Beiträge: 2
  • Registriert: Mi Mär 08, 2017 12:53 pm
  • Wohnort: http://seocando.ir/


+ Antwort erstellen

Seite 1 von 1