473,387 Members | 1,548 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,387 software developers and data experts.

{background-image} Question


Hello everyone...

If one has a <div> that is completely filled with a
background-image; how does one style it so that the
image *continues* to fill the <div> top-to-bottom,
left-to-right; if the viewer adjusts the font-size
on his browser? I have everything sized in em's,
so that the actual <div> "box" resizes along with the
text, but the background-image will not resize if the
text is "zoomed". I can not find anything pertaining
to something along the lines of "background-image-size";
or similar. Are there certain attributes for background-
position that can ensure this?

Thanks

--

Greg Heilers
Registered Linux user #328317 - SlackWare 10.1 (2.6.10)
.....

As far as anyone knows we're a nice, normal family.

-- Homer Simpson
There's No Disgrace Like Home

Nov 6 '05 #1
3 4959
In article <E6**************@newsread2.news.pas.earthlink.net >,
Greg Heilers <gN************@earthNOSPAMlink.net> wrote:
If one has a <div> that is completely filled with a
background-image; how does one style it so that the
image *continues* to fill the <div> top-to-bottom,
left-to-right; if the viewer adjusts the font-size
on his browser? I have everything sized in em's,
so that the actual <div> "box" resizes along with the
text, but the background-image will not resize if the
text is "zoomed". I can not find anything pertaining
to something along the lines of "background-image-size";
or similar. Are there certain attributes for background-
position that can ensure this?


I was looking at putting a background image on some links styled as
buttons, which seems a similar problem. In Opera the image is zoomed,
but in Safari only the text is zoomed, as you point out. I read
something about using * {zoom: 1.0;} as a way to get IE to zoom like
Opera, but that seems to be proprietary and the CSS validator doesn't
like it. However I haven't got IE so I don't even know if it works.

--
http://www.ericlindsay.com
Nov 6 '05 #2
Eric Lindsay wrote:
In article <E6**************@newsread2.news.pas.earthlink.net >,
Greg Heilers <gN************@earthNOSPAMlink.net> wrote:
If one has a <div> that is completely filled with a
background-image; how does one style it so that the
image *continues* to fill the <div> top-to-bottom,
left-to-right; if the viewer adjusts the font-size
on his browser? I have everything sized in em's,
so that the actual <div> "box" resizes along with the
text, but the background-image will not resize if the
text is "zoomed". I can not find anything pertaining
to something along the lines of "background-image-size";
or similar. Are there certain attributes for background-
position that can ensure this?


I was looking at putting a background image on some links styled as
buttons, which seems a similar problem. In Opera the image is zoomed,
but in Safari only the text is zoomed, as you point out. I read
something about using * {zoom: 1.0;} as a way to get IE to zoom like
Opera, but that seems to be proprietary and the CSS validator doesn't
like it. However I haven't got IE so I don't even know if it works.


Well...I removed the {background-image} attributes from the style section;
and used <img src="whatever.jpg" height=100% width=100%> within the actual
<div>, before overlaying it with the text. This *will* properly zoom
in Mozilla, Firefox, and Konqueror. Like you, though, I am currently in a
Microsoft-Free environment, and can not test it in IE.

--

Greg Heilers
Registered Linux user #328317 - SlackWare 10.1 (2.6.10)
.....

As far as anyone knows we're a nice, normal family.

-- Homer Simpson
There's No Disgrace Like Home

Nov 6 '05 #3
Greg Heilers <gN************@earthNOSPAMlink.net> wrote:
If one has a <div> that is completely filled with a
background-image; how does one style it so that the
image *continues* to fill the <div> top-to-bottom,
left-to-right; if the viewer adjusts the font-size
on his browser?
Background images by default repeat to "fill" their container, in CSS2.x
you cannot stretch them (background image stretching is part of the CSS3
proposals, but afaik not yet implemented by any browser).

Not many images look good when stretched, not helped by the fact that
browsers use fast but crude algorithms to do this.
I have everything sized in em's,
so that the actual <div> "box" resizes along with the
text


If the box with the background image contains text then it should be
sized using a relative unit, if you don't then your precious design will
often fall apart with varying user font settings.

If the box doesn't contain any text then there are no problems with
sizing it using the px unit.

Coding the image in the HTML with a 100% width and height creates it's
own problems if the box also contains text. You'd have to take the text
out of the flow to get it to display over the image, this will result in
overflow problems if the text wraps or if the viewport width isn't
sufficient.

The 100% width and height of an image coded in the HTML should be
specified in the CSS, or else the image will blow up to fill the
viewport when the user has CSS disabled of if it doesn't load for some
reason.

--
Spartanicus
Nov 6 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanimir Stamenkov | last post by:
Here are two cases regarding inline-level elements' line-height, padding and background, which I doesn't understand: <div style="background: black; color: white; line-height: 1.5">...
1
by: CMAR | last post by:
I have a design of a frameless page on my practice website: http://home.ne.rr.com/thespar/designerN.htm The idea is to have a #left navigation bar which is absolutely positioned and which...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
2
by: bissatch | last post by:
Hi, I am running a w3c CSS validation check on a site in development. I have many errors saying that my CSS is not valid because I have not defined the background-color but instead left it...
6
by: Francois Bonzon | last post by:
Any idea how I can launch a background task from a PHP script? For example, when a user posts on my message board, it may fire many e-mail notifications to other users, and other tasks. I want...
0
by: Jeb Hunter | last post by:
Well, how can I describe this succinctly? I have a page with DIVs that us background images to produce a border effect. It works perfectly well, but I want to make up (for now) 3 different...
2
by: darkpowrjd | last post by:
I've been trying to create a new navigation system for my site, and I got everything figured out except for one thing. Here is the CSS code I'm using right now: body { font: normal 10px Verdana,...
8
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In...
7
by: arupfrancis | last post by:
Hi, I am trying to create a colored box using background images. I am able to do it easily using tables but doing it in divs is proving to be an issue. Moreover IE and Mozilla also seems to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...
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...

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.