Hello,
I want to make the whole <li> element a link and clickable. here is my code that I have: -
#nav {
-
background-color:#99CCFF;
-
border-color:#000066;
-
border-style:solid;
-
border-width:.75px;
-
width:150px;
-
height:700px;
-
}
-
-
#menu {
-
list-style-type:none;
-
padding-left:4px;
-
margin:0px;
-
}
-
-
#menuitem {
-
width:140px;
-
border-style:solid;
-
border-color:#000000;
-
border-width:.75px;
-
padding-top:5px;
-
}
-
-
#nav a, #nav a:visited {
-
text-decoration:none;
-
color:#000000;
-
-
}
-
-
#menuitem li:hover {
-
background-color:#CCCCCC;
-
}
-
-
<div id="nav">
-
<ul id="menu">
-
<a href="index.htm" id="menulink"><li id="menuitem">Home</li></a>
-
<a href="bio.htm" id="menulink"><li id="menuitem">Bio</li></a>
-
<a href="articles.php" id="menulink"><li id="menuitem">Articles</li></a>
-
<a href="clients.php" id="menulink"><li id="menuitem">Clients</li></a>
-
<a href="links.htm" id="menulink"><li id="menuitem">Links</li></a>
-
</ul>
-
</div>
-
Does anyone have any suggestions?
10 1964
'id' is a unique name which is given to one element only. If you must use the same style for multiple elements, use 'class'.
You are using :hover for the <li> element. This will only work in modern browsers and not IE6.
'id' is a unique name which is given to one element only. If you must use the same style for multiple elements, use 'class'.
You are using :hover for the <li> element. This will only work in modern browsers and not IE.
I know I know, i was trying to use the hover for style. But I want to make the whole <li> clickable. Do you know how to do this?
You cannot have the <a> outside the <li> because <a> will be treated as another element, which would be illegal for an <ul>.
So, <li><a href.......
Then, in css, you need to make the <a> extend the width of the <li>. But <a> is inline while <li> is block level. So:
ul li a{display:block;width:200px}
Another way to do that is position it:
ul li a{float:left;width:200px;}
The float is necessary to position it but you can use any positioning method, I think. Don't recall if you also have to position the <li> to the same width as the <a>.
You cannot have the <a> outside the <li> because <a> will be treated as another element, which would be illegal for an <ul>.
So, <li><a href.......
Then, in css, you need to make the <a> extend the width of the <li>. But <a> is inline while <li> is block level. So:
ul li a{display:block;width:200px}
Another way to do that is position it:
ul li a{float:left;width:200px;}
The float is necessary to position it but you can use any positioning method, I think. Don't recall if you also have to position the <li> to the same width as the <a>.
Ok, I'm a little slow. I'm creating a Vertical Menu... Not horizontal for which the float left is necessary.
Do you know how this could work with a vertical menu?
Perhaps you read my post before I edited it. Use the css for 'display:block'.
Have I ever told you, you're my hero.
Thanks for pointing me in the right direction. That really helped a lot.
Remember, you are the wind beneath my wings.
Javascript would make that so easy! No need to expand the <a> n such. -
<script type="text/javascript" language="javascript">
-
function goToLink(url){
-
window.location = "http://"+url+""
-
}
-
</script>
-
-
<a onclick="goToLink('url_here')">go to</a>
-
Sorry if i strayed from your question.
Javascript would make that so easy! No need to expand the <a> n such. -
<script type="text/javascript" language="javascript">
-
function goToLink(url){
-
window.location = "http://"+url+""
-
}
-
</script>
-
-
<a onclick="goToLink('url_here')">go to</a>
-
Sorry if i strayed from your question.
I try to stay away from javascript. We got into a drunken argument and we don't really talk anymorre
Javascript would make that so easy! No need to expand the <a> n such. -
<script type="text/javascript" language="javascript">
-
function goToLink(url){
-
window.location = "http://"+url+""
-
}
-
</script>
-
-
<a onclick="goToLink('url_here')">go to</a>
-
Sorry if i strayed from your question.
I don't see how all that is simpler than:
ul li a{display:block;width:200px}
Plus it works even if js is disabled.
I don't see how all that is simpler than:
ul li a{display:block;width:200px}
Plus it works even if js is disabled.
I concur with your findings
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dr. zoidberg |
last post by:
Hello, I'm creating simple menu.
MySQL:
+----+-----+----------------------+
| id | sid | Title |
+----+-----+----------------------+
| 1 | 0 | Main Menu 1
| 2 | 0 | Main Menu 2
| ...
|
by: Michael Champagne |
last post by:
Does anyone have any examples or links to examples of generating a
simple unordered list menu with multiple levels from an XML file? We
are redesigning the navigation on our website and I was...
|
by: BenOne© |
last post by:
Hi all,
I'm learning CSS, and relearning HTML so I can build a website for myself, and I
was wondering if someone could help me with what seems like a simple layout that
I want to maintain no...
|
by: trialanderror |
last post by:
Both of these apply to using IE 6.0 or Netscape 7.x:
First question:
I am trying to set up a simple horizontal menu as a red strip across
the browser window. Here is the relevant part of the...
|
by: Paul |
last post by:
HI! I get an error with this code.
<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>
Basicly I want my iframe to have a default page if the user enters in...
|
by: Sergio |
last post by:
for my web site I am looking for a simple PHP plain text menu system, the
menu would have at least four levels and about 200 links, at starting only
the main levels should appear, for example :
...
|
by: Rob Somers |
last post by:
Hey all
I am writing a program to keep track of expenses and so on - it is not
a school project, I am learning C as a hobby - At any rate, I am new
to structs and reading and writing to files,...
|
by: tricard |
last post by:
Good evening,
I was thinking about making a very simple DOS based (console) menu for
a project that i am working on, but I have no idea where to start for
something like this. Does anyone have...
|
by: yefei |
last post by:
i want to display a price lists according to the product groups the
user select.
the designer gave to me is to show the product groups use a tab menu,
which can enlarge a little bit, when user...
|
by: Timmah1980 |
last post by:
I'm sure this is a simple enough fix for someone out there, but I'm
afraid it's beyond me!
I'm putting together this simple menu for a client:
http://www.timkeay.co.uk/mpc2/index.htm
It...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |