CSS Reset script interfering with 1 link - html

I have a menu which can be seen in the link below:
http://fiddle.jshell.net/V88c6/8/show/
Here is the full jsfiddle
http://jsfiddle.net/V88c6/8/
Here is the HTML
<div id="head_1">
<div class="inner">
<div class="column_0">
LOGO
</div>
<div class="column_1">
LINK 1
LINK 2
LINK 3
LINK 4
</div>
<div class="column_2">
<span>USER NAME</span> LOGOUT
</div>
<div class="clearfix"></div>
</div>
</div>
For some reason the LOGOUT link's top border on hover seems to be a pixel higher then the rest of the links. This happened when I added some css reset script.
Here is a link of the same page without the css reset where the LOGOUT link works fine:
http://fiddle.jshell.net/V88c6/9/show/
I like to use the css reset script to help the page look similar on most popular browsers.
Anyone know why the css reset script would be interfering with the LOGOUT link only?
Tested on IE7, IE8, Latest Google Chrome, latest Firefox, Latest Opera.

You are trying to style it the bad way. Try styling it like this - whit li ul:
<div class="column_1">
<ul class="menu_link">
<li><a href="#" >LINK 1</a></li>
<li><a href="#" >LINK 2</a></li>
<li><a href="#" >LINK 3</a></li>
<li><a href="#" >LINK 4</a></li>
<ul>
</div>
<div class="column_2">
<ul class="menu_link">
<li>username</li>
<li><a href="#" >LINK 4</a></li>
<ul>
</div>
and these are the selectors:
.menu_link li{}
.menu_link li a{}

you can try this one also
#head_1 .inner .column_2 {
display: block;
float: right;
padding: 0 15px;
}
#head_1 .inner .column_2 .menu_link {
border-top: 17px solid transparent;
padding: 17px 15px 10px 15px;
display: inline-block;}

The problem has to do with the computed value for the display property.
Your middle column with "LINK 1" and so on shows .menu-link with float: left, which causes the <a> elements to be block instead of inline.
You "LOGOUT" link shows .menu-link with no float, so the <a> element is inline.
The inline element affects the height of its inline box differently from a block element.
There was some style property in your browser's default style sheet that was masking this effect, and when you used a reset CSS style sheet, it appears.
The fix would be to layout out the two elements on the right (User Name and Logout) as floated element or to tweak the margin or line height by 1-2 px (involves trial and error, groaning).
The Fix
I was able to get a consistent layout by doing the following by adjusting your CSS as follows:
#head_1 .inner .column_2 {
display:block;
float:right;
/* padding:34px 0px 10px 15px; Remove this... */
}
#head_1 .inner .column_2 .menu_link{
border-top:17px solid transparent;
padding:17px 15px 10px 15px;
float: left; /* add this.. */
}
/* Float your span like you floated the link... */
#head_1 .inner .column_2 span {
border-top:17px solid transparent;
padding:17px 15px 10px 15px;
float: left;
}
Fiddle: http://jsfiddle.net/audetwebdesign/Myhcy/
The key is to keep a consistent coding style in laying out your two menus.

Related

Decorating list items like buttons

I'm wondering what some good practices are for styling li elements like buttons. Any examples would be appreciated. I'm guessing a box shadow and a background color would go a long way, but that alone does not seem to be enough.
Edited the question to make it more useful.
Okay I think what your after is to make the whole link clickable rather than just the text. All you need to do is make your anchor a block element, then it will take the full width of the li:
.nav a {
display:block;
}
<ul class="nav">
<li>Home</li>
<li>About us</li>
</ul>
I assume you try to make menu and want bigger buttons than just link text.
You should set links inside list elements as you shown and then make links as buttons.
Very simple css example for horizontal menu would be something like this:
.nav li {
list-style-type: none;
padding 0px;
margin 0px;
float: left;
}
.nav li a {
text-decoration: none;
display: block;
padding: 0px 15px;
line-height: 25px;
}
For horizontal menu you should make width with padding and height with line-height. Unless you want every button to be same sized, then you just could use width.
More in-depth example would be this one http://medialoot.com/blog/how-to-create-a-responsive-navigation-menu-using-only-css/
I think your issue may be that you have styled the <li> to look like the menu button, but the text is the only part that is clickable, is this correct?
What you need to do, is not style the <li> as the menu button but instead the <a> within it.
Here is a demo: https://jsfiddle.net/arrx7dL7/
As you can see the styles are applied to the links, rather than the li
HTML:
<ul class="menu">
<li><a class="menu-item" href="#">Item 1</a></li>
<li><a class="menu-item" href="#">Item 2</a></li>
<li><a class="menu-item" href="#">Item 3</a></li>
<li><a class="menu-item" href="#">Item 4</a></li>
</ul>
CSS:
.menu {
list-style:none;
}
.menu-item {
color:black;
text-decoration: none;
background: #eee;
border: 1px solid #ccc;
padding:20px 30px;
display:block;
}
I think this is what you mean, if so I hope it is helpful.

How do I make my background-color fill entire width of div when applied to a `ul li`?

I'm using jQuery-UI-Layout plugin that creates a pane on the east side of the screen. When I create a list in it and apply a background-color to each <li> element, it doesn't span the width of the entire pane.
I would like it so that there is no white space on either side of the <li>, even if it has a bullet or number next to it (meaning if I decide to include a bullet or number, it should also be covered by the color). How can I do this?
Fiddle: http://jsfiddle.net/5EECD/497/
HTML:
<div class="ui-layout-center">Center</div>
<div class="ui-layout-east">
<ol id="someList">
<li class="not-selected">step 1</li>
<li class="selected">step 2</li>
<li class="not-selected">step 3</li>
<li class="not-selected">step 4</li>
</ol>
</div>
CSS:
.selected {
background-color: #e90902;
padding-top: 10px;
border-bottom: 1px solid #808080;
padding-bottom: 10px;
}
.not-selected {
padding-top: 10px;
padding-bottom: 10px;
background-color: #e9e9e9;
border-bottom: 1px solid #808080;
}
Add this to your CSS file:
.ui-layout-pane-east {
padding: 0 !important;
}
Don't do this from the browser's inspector. jQuery UI's inner workings are supposed to calculate widths on page load.
Try Removing the
padding: 10px
from the following in css
body > div.ui-layout-east.ui-layout-pane.ui-layout-pane-east
It might not be the best way of doing it, though you can expand the margins of the <li> to fill the pane.
li{
margin: 0px -10px 0px -10px;
}
JSFiddle
Here is your edited working Fiddle, with a List Style Disc "inside" the actual list item, by using the list-style-position style. To remove the Disc icon, simple use the style "none" instead.
If you set the font-size to 0px and that will remove all white space from list items, as long as the list item has a given font size which is shown in the example.
I just added a little CSS to your working CSS:
ol#someList {
font-size:0px;
padding-left:0px;
list-style:disc;
list-style-position: inside;
}
ol#someList li {
font-size:14px
}
I also added a body style to remove the default margin of 8px to show you that there is no white space to left or right of the list items.
Hope that helps!
Michael G

Issue in Pure CSS3 LavaLamp Tab menu Hover

I implemented the Lavalamp tab menu in my website: when Mouse goes on absolute Div "#lavalamp" bottom "subs" div not display.How to fixed this, please help me.
Detail code click here
<ul id="nav">
<li><a class="hsubs" href="#">Magento</a>
<div class="subs colbg01">
Submenu 1
</div>
</li>
<li><a class="hsubs" href="#">Wordpress</a>
<div class="subs colbg02">
Submenu 2
</div>
</li>
<li><a class="hsubs" href="#">Mobile App</a>
<div class="subs colbg03">
Submenu 3
</div>
</li>
<div id="lavalamp"></div>
The problem happens when you hover over the triangle, which causes the underlining li to lose its own hover and thus invalidating the active li:nth-child(..) ~ #lavalamp rule.
You can solve this issue with modern browsers by disabling the pointer events on the lavalamp element
#lavalamp{pointer-events:none;}
demo at http://jsfiddle.net/gaby/6Lmgkhxd/4/
Notice: IE added support for pointer-events on v11
The reason this is not working is because the hover state of the li is being broken when hovering over the #lavalamp element (which appears later in the DOM).
If you really want a CSS only fix you can use z-index to place the triangle behind everything else and bring the li forward.
like:
#nav li {
float: left;
display: block;
padding: 16px 20px 18px 20px;
z-index: 1; // <--- added this
}
#lavalamp {
z-index: -1; // add this
... other code
}
example: http://jsfiddle.net/6Lmgkhxd/3/
I changed the li's background-color to transparent to allow this to work.
Also there seems to be a slight gap between the li and the.subs so I increased the bottom padding of the li to overlap better to the 50px top positioned .subs (from 16px to 18px)

Hide un-classed element, and show it's sibling?

I've got some HTML code I can't modify. I don't want to use JS/jQuery to do this, would like to get it done with cross-browser friendly CSS.
The HTML looks like this:
<ul class="list">
<li class="item">
<a href-"#">Item One</a> |
</li>
<li class="item">
<a href-"#">Item Two</a> |
</li>
<li class="item">
<a href-"#">Item Three</a> |
</li>
</ul>
It's got those stupid pipes in there to break up the list. I Want to hide those, and show the <a> elements. I don't just want to make the text color the same as the background either. I'd like an equivalent of display: none;
You can set the font-size of the li to 0 and give it a transparent color, then set those properties back to normal on the a:
li.item {
font-size: 0;
color: transparent;
}
li.item a {
font-size: 16px;
color: #000;
}
This makes the li text invisible and have no size whatsoever, but keeps the a element styled as it should.
JSFiddle demo.
Note that I've used transparency here as (as far as I recall) Safari has a problem with fully hiding the font when its size is set to 0.
Simply:
.item {
color: transparent;
}
.item a {
color: #000;
}
JS Fiddle demo.
This means that the text of the li is invisible/transparent (though it can still be selected), but the text colour of the a element is made visible.

Putting <br> in a horizontal <ul> breaks it?

This is the code for a horizontal <ul> that I'm using:
.list ul{
width: 100%;
}
.list li{
display: inline;
list-style-type: none;
padding-right: 20px;
padding-bottom: 20px;
}
Using this, if I do this:
<ul class="list">
<li>
<img src="myImg.png" />
<span class="edit"></span>
<span class="delete"></span>
</li>
</ul>
Then it all works, however if I put a <br> between the image and the edit/delete buttons, e.g:
<ul class="list">
<li>
<img src="myImg.png" />
<br />
<span class="edit"></span>
<span class="delete"></span>
</li>
</ul>
Then the list breaks, and I get the images in a vertical list instead of horizontal. Screenshot when its working:
Screenshot of when its not working:
Any ideas?
Replace the
display: inline
with
float: left
Example fiddle
The solution is to use: display:inline-block on your li element which then allows all other markup to function correctly, both in and out of your list.
inline-block: The element is placed as an inline element (on the same line as adjacent content), but it behaves as a block element
Here is a jsfiddle showing an example.
The above jsfiddle is now edited to support older IE7 to work alongside modern browsers. The order of the .css for display is important. To throw in support for IE6, then additonal _height: 30px; where 30 is your required height needs to be added. But IE6 browser use is less than 1%.
Try to use for .list li { float:left; } instead { display:inline; } and will work.