473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do you atuo-size a wordpress background image?

I am needing to find out how to make the background image on my site auto-sized based off of the resolution of a users screen. I want it to fit proportionately with the images/text in the same spot on the background. I am pretty close because I can have exactly what I want at a certain screen resolution, but it does not auto-fit at other resolutions. The images and text get pushed behind the content of the page instead of being off to the side. It also does not work on firefox or Ie. Please help me to find a fix for this. here is the code that I have right now.

[code]

/* Architecture */
html { }

body {

background: #000000;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #bcbcbc;
background: #fff url(http://i1207.photobucket.com/albums/bb474/jonathanhowardguitar/banddynamics.jpg?t=1287710849);
background-size: 100%; background
background-repeat: no-repeat;
background-attachment: fixed;
<style type="text/css">

[code]
Oct 22 '10 #1
7 3217
Death Slaught
1,137 1GB
Don't give the background image to the body. Place a div inside of the body,

Expand|Select|Wrap|Line Numbers
  1. <div id="container"></div>
Place all of your content inside of this as if it were the body element.

Move the background image to the div and set the width/height to desire percentage.

Expand|Select|Wrap|Line Numbers
  1. #container {
  2.     background-image: url('http://i1207.photobucket.com/albums/bb474/jonathanhowardguitar/banddynamics.jpg?t=1287710849'); 
  3.     width:100%;
  4.     height: 100%;
  5. }

Thanks, Death
Oct 25 '10 #2
Death Slaught
1,137 1GB
I apologize, I just realized that my example only works without a doctype, and is a little sketchy. I'll try and look at this again first thing tomorrow.


Regards, Death
Oct 29 '10 #3
Death Slaught
1,137 1GB
To accomplish this you will need to use absolute positioning and z-index. Example


Regards, Death
Oct 29 '10 #4
JKing
1,206 Expert 1GB
Here is a site you can use as an example. http://www.quebecregion.com/en/where_to_stay?a=vis

If you view the source you can see how they are using an img tag inside a div with a lower z-index than the wrapper. This allows them to set the img height to auto and the width to 100% resizing the "background".
Oct 29 '10 #5
Death Slaught
1,137 1GB
I was just editing my post to add an explanation, but JKing took care of that for me. :) I often forget to add explanations or overlook something because I'm posting while in class.


@JKing
If the user has the window itself resized the page only compensates to a point.


Thanks, Death
Oct 29 '10 #6
JKing
1,206 Expert 1GB
They also have a min-width:815px; on the img tag so that stops it from going really small but if you were to remove that it would go smaller.
Oct 29 '10 #7
Death Slaught
1,137 1GB
<-------- had Firefox displaying the wrong set of styles on elements when inspecting them. That explains sooo much. I probably wouldn't have noticed had you not mentioned the min-width, so thank you.
Oct 29 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: msnews.microsoft.com | last post by:
Hi Every One, I put a question befor about auto email alters, I got the answer that build a window service that auto email to the users. But How Service Execute. Means Window Service has methos...
0
by: =?Utf-8?B?SmF5ZQ==?= | last post by:
I have created the programme, then using the font in Office 2007. However the user's PC haven't install the font style, when i publish my programme by clickonce, and the user use it, the font style...
4
The1corrupted
by: The1corrupted | last post by:
Is there a method in PHP to have an entirely automatic update of a mySQL database at midnight of each day?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.