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

Background with



Hi i got the problem to get a horizontal css-menu working with
background image.

if i use
display:block;
under #list a, the image is shown but the list is vertical.

When i use display:inline; no image is shown and i can't use a fixed width.

Ist there a way to get a horizontal list weoking with background image
and fixed width?

---------------------------------
my code:
---------------------------------
<ul id="list">
<li><a href="#">Testlink</a></li>
<li><a href="#">Testlink</a></li>
<li><a href="#">Testlink</a></li>
<li><a href="#">Testlink</a></li>
</ul>
---------------------------------
my Stylesheet
---------------------------------
#list ul{
margin:0;
padding:0px;
list-style:none;
display:inline;
white-space: nowrap;}

#list li{
width:109px;
list-style-image: none;
display:inline;
}

#list a{
text-align:right;
background-image: url(img/navi-inaktiv.gif);
background-repeat: no-repeat;
display:inline;
height: 23px;
background-position: right;
}
-----------------------------------
Jul 21 '05 #1
8 1559
Wilhelm Kutting <wk******@arcor.de> wrote in
news:d2**********@newsreader3.netcologne.de:
Ist there a way to get a horizontal list weoking with background image
and fixed width?


The way that always works best for me is to utilize floats. Each li tag
is floated left and the ul is centered or whatever you like. Then, you
can specify each width for the li tags, and they'll be horizontal
rather than vertical.

--
Arctic Fidelity <sp**@sacrificumdeo.net>
<http://www.sacrificumdeo.net>
"Beware of bugs in the above code; I have only proved it correct, not
tried it." -- Donald Knuth

Jul 21 '05 #2
Wilhelm Kutting wrote:


Hi i got the problem to get a horizontal css-menu working with
background image.

if i use
display:block;
under #list a, the image is shown but the list is vertical.

When i use display:inline; no image is shown and i can't use a fixed width.

Ist there a way to get a horizontal list weoking with background image
and fixed width?

---------------------------------
my code:
---------------------------------
<ul id="list">
<li><a href="#">Testlink</a></li>
<li><a href="#">Testlink</a></li>
<li><a href="#">Testlink</a></li>
<li><a href="#">Testlink</a></li>
</ul>
---------------------------------
my Stylesheet
---------------------------------
#list ul{
margin:0;
padding:0px;
list-style:none;
display:inline;
white-space: nowrap;}

#list li{
width:109px;
list-style-image: none;
display:inline;
}

#list a{
text-align:right;
background-image: url(img/navi-inaktiv.gif);
background-repeat: no-repeat;
display:inline;
height: 23px;
background-position: right;
}
-----------------------------------


use
<li><a ...> blabla </a></li>

and make li display:inline and a:display:block
Jul 21 '05 #3
"Martin!" <m.*******@gmail.komkommer> wrote in
news:d2**********@news3.zwoll1.ov.home.nl:
Ist there a way to get a horizontal list weoking with background
image and fixed width?


use
<li><a ...> blabla </a></li>

and make li display:inline and a:display:block


This seems like rather poor coding style. I'm not sure, but wouldn't it
be better and more reliable to use floats rather than to swap the
displays like that? In addition, isn't there some major issues with
putting blocks within an inline tag?

--
Arctic Fidelity <sp**@sacrificumdeo.net>
<http://www.sacrificumdeo.net>
"Beware of bugs in the above code; I have only proved it correct, not
tried it." -- Donald Knuth

Jul 21 '05 #4
Arctic Fidelity wrote:
"Martin!" <m.*******@gmail.komkommer> wrote in
news:d2**********@news3.zwoll1.ov.home.nl:

Ist there a way to get a horizontal list weoking with background
image and fixed width?


use
<li><a ...> blabla </a></li>

and make li display:inline and a:display:block

This seems like rather poor coding style. I'm not sure, but wouldn't it
be better and more reliable to use floats rather than to swap the
displays like that? In addition, isn't there some major issues with
putting blocks within an inline tag?


http://css.maxdesign.com.au/listamatic/

convince yourself
Jul 21 '05 #5
Arctic Fidelity wrote:
"Martin!" <m.*******@gmail.komkommer> wrote in
news:d2**********@news3.zwoll1.ov.home.nl:

Ist there a way to get a horizontal list weoking with background
image and fixed width?


use
<li><a ...> blabla </a></li>

and make li display:inline and a:display:block

This seems like rather poor coding style. I'm not sure, but wouldn't it
be better and more reliable to use floats rather than to swap the
displays like that? In addition, isn't there some major issues with
putting blocks within an inline tag?


Essentially you are right in saying that an inline element may not
contain a block element. An inline element with the display property set
to block, will cause it to be displayed as a block, but will still be an
inline element. The display property, in CSS, does not change the HTML
type from inline to block or vice-versa, but only "how it will be
displayed".

For example:
BODY may contain only a block element.
IMG is an inline element.
Therefore, IMG may not be directly in BODY.

img {display:block;} will cause IMG to be displayed as a block.
IMG will still be an inline HTML element irregardless of the CSS display
property.
IMG may still not be directly in BODY.

Similarly, A (anchor) is an inline HTML element and will always be an
inline element no matter if CSS changes the display property to block.

--
Gus
Jul 21 '05 #6
Gus Richter <gu********@netscape.net> wrote in
news:6L********************@golden.net:
Arctic Fidelity wrote:
"Martin!" <m.*******@gmail.komkommer> wrote in
news:d2**********@news3.zwoll1.ov.home.nl:

and make li display:inline and a:display:block

This seems like rather poor coding style. I'm not sure, but wouldn't
it be better and more reliable to use floats rather than to swap the
displays like that? In addition, isn't there some major issues with
putting blocks within an inline tag?


Essentially you are right in saying that an inline element may not
contain a block element. An inline element with the display property
set to block, will cause it to be displayed as a block, but will still
be an inline element. The display property, in CSS, does not change
the HTML type from inline to block or vice-versa, but only "how it
will be displayed".


Thanks, that clarifies something. Hehe, I was thinking that CSS would
change the natural "semantic" nature of an element, which I guess it
doesn't. :-)

--
Arctic Fidelity <sp**@sacrificumdeo.net>
<http://www.sacrificumdeo.net>
"Beware of bugs in the above code; I have only proved it correct, not
tried it." -- Donald Knuth

Jul 21 '05 #7
Arctic Fidelity wrote:
Gus Richter <gu********@netscape.net> wrote in
news:6L********************@golden.net:

Arctic Fidelity wrote:
"Martin!" <m.*******@gmail.komkommer> wrote in
news:d2**********@news3.zwoll1.ov.home.nl:

and make li display:inline and a:display:block
This seems like rather poor coding style. I'm not sure, but wouldn't
it be better and more reliable to use floats rather than to swap the
displays like that? In addition, isn't there some major issues with
putting blocks within an inline tag?


Essentially you are right in saying that an inline element may not
contain a block element. An inline element with the display property
set to block, will cause it to be displayed as a block, but will still
be an inline element. The display property, in CSS, does not change
the HTML type from inline to block or vice-versa, but only "how it
will be displayed".

Thanks, that clarifies something. Hehe, I was thinking that CSS would
change the natural "semantic" nature of an element, which I guess it
doesn't. :-)


This was clarified for me as well in this newsgroup not too long ago.

--
Gus
Jul 21 '05 #8
Gus Richter <gu********@netscape.net> wrote in news:N66dnQXJFaeSdc7fRVn-
tg@golden.net:
This was clarified for me as well in this newsgroup not too long ago.


Yeah, I'm learning all sorts of cool stuff on this group that I didn't
even know existed. :-)

--
Arctic Fidelity <sp**@sacrificumdeo.net>
<http://www.sacrificumdeo.net>
"Beware of bugs in the above code; I have only proved it correct, not
tried it." -- Donald Knuth

Jul 21 '05 #9

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

Similar topics

4
by: erik | last post by:
Is it posssible to inherit the previous pages (parent pages) background image? Is there a script out there I could look at? Thanks
2
by: Markus Mohr | last post by:
Hi, everyone, I have a special problem: For every monitor resolution in 200 pixel steps from 800 to 1600 pixels I have an image to be shown as centered background-image. Those images all...
11
by: Konrad Den Ende | last post by:
I have a function returning a string but the problem is that the color of it is blue which suits me well for some pages but not for others. Is it possible to "feel" what the color of the background...
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 | +---+---+
5
by: proximus | last post by:
Hi, I am trying to change the background of table TD's. The problem is that I have no access to the HTML code. SO I am trying to alter this using Javascript/DOM in an external .js file. I...
3
by: Viken Karaguesian | last post by:
Hello all, I need somehelp with background tiling. I have a sneaking suspicion that what I want to do is not possible, but I'll ask anyway. :>) First some background: Here's the site in...
1
by: nicky77 | last post by:
Hi, I've created a nav bar using a background image for rollover effects. Everything works as I had hoped, however, for some reason it seems that an area of whitespace (the same size of the...
16
by: stevedude | last post by:
CSS newbie again. I have a problem trying to get coffee mug images within anchor tags to center with my link text for a vertical list menu. If I use the horizontal/vertical properties of...
19
by: david.karr | last post by:
If in my CSS I set the "background-color" property on the "body" element, it only covers the background of the elements defined in the body, up to the current width and height of the page. However,...
2
by: thephatp | last post by:
I'm having a problem with IE rendering correctly. I'm experimenting with using all div's in my pages now, and I'm not very familiar with the quirks of IE. I have created a sample page, and I'm...
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
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
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
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,...
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
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
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...
0
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,...

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.