Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help to image background compleate

Featured Replies

Hello, I have a problem with my web page, I have an image background and I need that this background fit on all resolutions screens

so I have an image of 200x 1400, I think this have to fit on big resolution screens , I have a code that it supposed to do that and it works, but only on wide , not on hight and is strange because the image is longer.

 

If I add on the pageBackground style min-height:1400px; max-height:1600px; , it show all the image, but the content have a scroll and

I don´t need the scroll.

 

Can someone help me ?? thanks in advance!!!

 

the web page is www.voltajecolectivo.com

 

here is the code:

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>RHED NL</title>

<link href="styles.css" rel="stylesheet" type="text/css" />

<style type="text/css">

body {

background-image: url(images/siteBackground.jpg);

background-repeat: no-repeat;

}

</style>

<script type="text/javascript">

function MM_swapImgRestore() { //v3.0

var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_preloadImages() { //v3.0

var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}

}

 

function MM_findObj(n, d) { //v4.01

var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];

for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);

if(!x && d.getElementById) x=d.getElementById(n); return x;

}

 

function MM_swapImage() { //v3.0

var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

</script>

</head>

 

<body onload="MM_preloadImages('images/btn_productosOver.png','images/btn_faqOver.png','images/btn_contactoOver.png','images/btn_calculadoraOver.png','images/btn_quienesSomosOver.png','images/btn_home.png')">

<div class="pageBackground">

<!-- begin #container -->

<div id="container">

<!-- begin #header -->

<div id="header">

<div class="logo"></div>

<div class="author"></div>

<div class="slogan1"></div>

<div><table width="799" border="0" cellpadding="2" cellspacing="2">

<tr>

<td width=281 height="27" valign="bottom"> </td>

<td width="293" rowspan="4"> </td>

<td width="205" height="27"> </td>

</tr>

<tr>

<td width=281 rowspan="3" valign="bottom"><img src="images/logo.png" width="251" height="62" alt="logo" /></td>

<td height="36" valign="bottom"> </td>

</tr>

<tr>

<td height="33" align="right" valign="bottom"><img src="images/face.png" alt="" width="105" height="30" usemap="#Map" /></td>

</tr>

<tr>

<td height="34" valign="top"><img src="images/correo.png" width="209" height="27" alt="correo" /></td>

</tr>

</table>

</div>

 

<div class="mainMenu"></div>

</div>

<!-- end #header -->

<!-- begin #mainContent --><img src="images/cuadro_central.png" width="800" height="419" alt="recuadro_central" /><!-- end #mainContent -->

<br class="clearfloat" />

<!-- begin #footer -->

<div id="footer">

<table width="103%" border="0">

<tr>

<td width="15%" align="center"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btn_home','','images/btn_home.png',1)"><img src="images/btn_homeOver.png" width="81" height="30" id="btn_home" /></a></td>

<td width="18%" align="center"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btn_quienesSomos','','images/btn_quienesSomosOver.png',1)"><img src="images/btn_quienesSomos.png" width="105" height="30" id="btn_quienesSomos" /></a></td>

<td width="17%" align="center"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btn_productos','','images/btn_productosOver.png',1)"><img src="images/btn_productos.png" width="124" height="30" id="btn_productos" /></a></td>

<td width="18%" align="center"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btn_faq','','images/btn_faqOver.png',1)"><img src="images/btn_faq.png" width="59" height="30" id="btn_faq" /></a></td>

<td width="18%" align="center"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btn_contacto','','images/btn_contactoOver.png',1)"><img src="images/btn_contacto.png" width="104" height="27" id="btn_contacto" /></a></td>

<td width="14%" align="center"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btn_calculadora','','images/btn_calculadoraOver.png',1)"><img src="images/btn_calculadora.png" width="128" height="38" id="btn_calculadora" /></a></td>

</tr>

</table>

<p> </p>

</div>

<div id="footer">

<table width="103%" border="0">

<tr>

<td align="left"><img src="images/logo_voltaje.png" alt="logo_voltaje" width="244" height="55" usemap="#Map2" /></td>

</tr>

</table>

<p> </p>

</div>

<!-- end #footer -->

</div>

<!-- end #container -->

<div id="footer_down">

 

</div>

 

<!-- end #footer -->

<td height="100%"></div>

 

<!-- begin #container -->

 

<map name="Map" id="Map">

<area shape="rect" coords="2,1,102,30" href="http://www.facebook.com/rhed.nl?fref=ts" target="new" alt="" />

</map>

</body>

</html>

 

 

 

 

* {

margin:0px;

padding:0px;

}

body {

font-family:Arial, Helvetica, sans-serif;

font-size:12px;

background: #003e63 url(images/siteBackground.jpg) repeat-x left top;

color: #ffffff;

}

a {

color:#ffe200;

text-decoration:underline;

}

a:hover {

color:#ffe200;

text-decoration:none;

}

.logo {

text-align:right;

color:#ffe200;

font-size:60px;

}

.logo span {

font-size:60px;

color:#FFF;

}

.author {

text-align:right;

margin-right:27px;

}

.author a {

color:#fff;

}

.slogan1 {

font-size:60px;

color:#FFF;

}

.slogan2 {

font-size: 60px;

color: #FFF;

text-align: left;

}

 

.correo {

font-size: 60px;

color: #FFF;

align: left;

}

.mainMenu {

padding:10px 0 0 0;

}

.mainMenu li {

list-style:none;

display:inline;

margin-right:50px;

}

.mainMenu li a {

color:#FFF;

font-size:24px;

text-decoration:none;

}

.mainMenu li a:hover {

color:#ffe200;

font-size:24px;

}

.mainMenu #active a {

color:#ffe200;

font-size:24px;

}

.pageBackground {

 

background: url(images/rhedfondoNUEVO2.jpg) no-repeat center top fixed;

-webkit-background-size: cover;

-moz-background-size: cover;

-o-background-size: cover;

background-size: cover;

min-height:1400px;

max-height:1600px;

 

 

 

 

}

#container {

width: 800px;

margin: 0 auto;

 

}

#header {

height:150px;

overflow:hidden;

}

#mainContent h2 {

color:#43f6d5;

font-size:14px;

font-weight:bold;

padding:20px 0 10px 0;

}

#mainContent h3 {

color:#37362b;

font-size:14px;

font-weight:bold;

padding:20px 0 10px 0;

}

.pageTop {

background:url(images/contentTop.png) no-repeat left top;

height:16px;

}

.pageBody {

background:url(images/contentBody.png) repeat-y left top;

padding:0 30px;

}

.freeWeb {

float:left;

width:265px;

}

.freeWebsiteTemplates li {

list-style:none;

margin:4px 0;

}

.professional {

margin-left:300px;

}

.freeWebsiteTemplates {

float:left;

width:210px;

background:#22bac4;

padding:0 0 30px 20px;

}

.freeWebsiteTemplates a {

color:#ffffff;

}

.facebookTemplates {

margin-left:250px;

}

.facebookTemplates img {

text-align:center;

border:0;

}

.pageFooter {

background:url(images/contentBottom.png) no-repeat left top;

height:19px;

}

#footer {

color:#8ba0a9;

text-align:center;

padding:20px;

 

}

#footer down{

color:#8ba0a9;

text-align:center;

height:300px;

padding:20px;

 

}

.clearfloat {

clear:both;

height:0;

font-size: 1px;

line-height: 0px;

}

This tutorial may help you:

http://css-tricks.co...ckground-image/

but if your image is only 200px wide in one direction it will look pixellated if stretched too much in a large resolution.

 

The first solution using CSS3 won't work in older browsers. I've used the position: fixed method for many years and haven't bothered to change to the CSS3 method yet.

Edited by Wickham

  • Author

thanks for answer, and I already tried this tutorial and for a reason it doesn´t works any method , I think that is because of the divs and tables that I need to have infront the image, or something like that because the image is more large that in the browser looks , it is cropping a part of the image.... if I make an enters on the div it make the complete image to appear but now I have a big scroll....someone can help me to solve this ??

 

thanks

The very simplest method is this:

CSS:

<style type="text/css">
.background { display: block; width: 100%; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: -1; }
</style>

HTML markup:

<img class="background" src="image.jpg" alt="Your image">

Put the html markup code immediately after the <body> tag, before all your content.

 

It will make the image fit the whole wimdow without cropping the sides because the position: fixed will be fixed to all the sides. However, it will distort the image which will look odd if you have a photo, but may be OK if you have a pattern. Omit bottom: 0; and the image will keep its aspect ratio but won't reach the bottom of the window at certain window sizes.

Edited by Wickham

Yes, I'm agree with Wickham. But you need to make little changes.

 

Remove this style from your css.

#bg img { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; min-width: 50%; min-height: 50%; height: 655px;]

 

Add This Code

#bg {display: block; width: 100%; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: -1;} 

 

 

Please, make sure your background size should be 1024px x 647px (I use this size and works perfect for me. You can try..)

 

Hope, your issue will be fix by this solution. If not, then let me know.

 

Thanks

Hem

Edited by Hem

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.