473,799 Members | 3,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.photobuck et.com/albums/bb474/jonathanhowardg uitar/banddynamics.jp g?t=1287710849) ;
background-size: 100%; background
background-repeat: no-repeat;
background-attachment: fixed;
<style type="text/css">

[code]
Oct 22 '10 #1
7 3226
Death Slaught
1,137 Top Contributor
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 Top Contributor
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 Top Contributor
To accomplish this you will need to use absolute positioning and z-index. Example


Regards, Death
Oct 29 '10 #4
JKing
1,206 Recognized Expert Top Contributor
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 Top Contributor
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 Recognized Expert Top Contributor
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 Top Contributor
<-------- 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
1025
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 like OnStart() and OnStop(). Starts execute when the service is started. But mostly servers starts one time and never shutdowns. Then how can i execute it. Actualy Our Scenario is We want to atuo emil to the registered user on every monday...
0
1021
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 is changed. So how can i publish my progamme by clickonce and the user will atuo install the font style before stasrt the programme
4
1164
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
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10228
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.