How to align middle slash image with links? - html

I have this css code http://jsfiddle.net/989Pd/ where the slash images must be in the middle of text height. How can I do it?
<div class="menu">
<div class="pedio940">
<ul>
<li>Αρχική</li>
<li>Προσθήκη RSS</li>
<li>Επικοινωνία</li>
</ul>
</div>
</div>

Instead of creating the slash as a background image, create it as an inline element and use the CSS: vertical-align:middle.
.menu ul li:after {
content:url("http://i.imgur.com/uB4Gz.png");
display:inline;
vertical-align:middle
}
Demo: http://jsfiddle.net/989Pd/8/
Edit: Yours is on the left, mine is on the right. I've drawn red lines to show the difference. They are not the same.

You can just adjust the height of the li
http://jsfiddle.net/989Pd/3/

put in a top value for the background like this: http://jsfiddle.net/989Pd/9/

Related

Creating full-height vertical menu in CSS

How can I force my tabs to take all the remaining space in the vertical menu? so, adjust the spaces between the tabs according to the number of tabs.
<div id="menu">
<ul>
<li>
<a class="lien_menu"><br>Onglet0 loooooooog</a>
</li>
<li>
<a class="lien_menu"><br>Onglet1</a>
</li>
</ul>
Here is my current code : http://jsfiddle.net/96EGh/
Thanks in advance.
Do you mean the fill the width or the height?
If you mean the height (as it's a vertical menu). You need to give your container a height so that the UL will fill it, and allow the LI elements to fill the rest of the space.
I've made a fiddle using a fixed height and display: table; / display: table-cell; to achieve this at http://jsfiddle.net/96EGh/3/
You can add more LI elements and they will fill the space.
you can do by css
ul{display:table;}
ul li{display:table-cell;}
You can do percentages.
ul li {width:48%;margin-right:1%;}
ul{width:100%}
Use percentages in width and Ems in font.

Why is there a gap between image and navigation bar

Hi I'm having some trouble removing a small gap between an image and my navigation bar. I've honestly tried just about everything i can think of. Setting inline-blocks on my ul and li level, and using text-align: left don't seem to be moving the hyperlinks to the left-most side of the div, and from there I'm not to sure what should be done. There is a padding, but it shouldn't be causing that much of a gap.
Here is the html code:
<div id = "header">
<img src ="img.png"/>
<div id ="nav_bar">
<ul class="nav">
<li class= "nav">Home</li>
<li class= "nav">Our Products</li>
<li class= "nav">Categories</li>
<li class= "nav">About Us</li>
<li class= "nav">Contact Us</li>
</ul>
</div>
</div>
Here's a jfiddle describing what I'm talking about.
http://jsfiddle.net/37VZb/1/
To clarify the gap I'm talking about is between the right of the image and the left most nav bar element.
That's because of a space character between inline(-block) elements. This could be fixed by commenting that space out this way:
<img src ="http://www.leapcms.com/images/100pixels1.gif"/><!--
--><div id ="nav_bar"> ...
JSFiddle Demo.
Similar topic on SO:
How to remove the space between inline-block elements?
And a good reference:
http://css-tricks.com/fighting-the-space-between-inline-block-elements/
Update
The remaining space belongs to the user agent applied style on the <ul> element.
Web browsers usually apply some padding on the list elements. To remove that set padding: 0; as follows:
ul.nav { padding : 0; }
Here is the Updated Fiddle.
is this what you mean? You can target the nav class on your ul and adjust the default margins that are being assigned
ul.nav{
margin: 10px 0;
}
JSFIDDLE
Your gap is a white space like you find in between words since both element are set as inline boxes. In your CSS you set as well somme padding to ul and a , they both are there.
http://jsfiddle.net/37VZb/8/
.nav_bar, .nav{
padding:0;
display:inline-block;
}
To get rid of it:
1) do not indent your code and get closing and opening brackets of element touch each other
2) add a CSScomment in between to swallow that white-space
3) set font-size to 0 (0.01px for IE) to parent of these inline-boxes and reset it ot back to 1rem (and or px/pt) for img (alt) and nav_bar
negative margin or negative letter-spacing are not to be used, it is not reliable and not meant to care about this

Problems positioning logo in navigation bar

I'm in the process of making a website, but am having issues positioning the logo in the navigation bar.
I've created a test version of the website at http://www.fearless-music.net/test
The logo isn't appearing in the center of it's space. In smaller browser windows, it hides behind the "Home" area of the navigation bar.
Also, are there any suggestions on code improvements I could make to my navigation bar?
Thanks again!
If you indent your code it is easier to see what's going on. Try adding the image in it's own div and enclosing it in p tags then you will be able to center it with the appropriate css rule. Tip when setting up divs using css add a colour border or background which you can later remove just to help with sizing and positioning.
<div class="header">
<div class="logo">
<p><img src="images/logo.png" alt="fearless music" /></p>
</div>
<ul class="nav">
<li class"currentpage">Home</li>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
<li>Link4</li>
<li>Special Link</li>
</ul>
</div>
It is centered in its space. Your list items align in the middle. All the widts of the <li> tags combined are not the same as the total width of the <ul>
Use your element inspector so you can see the outlines well
You need to remove the right padding from the ul. You will see that we have a left padding of 40px.
header ul {
padding-right: 0;
}
try changing lines 31 to this - so you can see you logo, you could also add back in your margin to get in centred back in the li, but I would suggest taking the logo out of the ul so that you can have more control over it.
.nav img {
/* vertical-align: middle; */
padding: 2px 0px;
}
Good luck I hope this helps :)

making span and ul on the same line

I have the following fiddle, I wanted to make the span and the ul text to be vertically aligned. Right now the ul text seems to be a bit shifted up a bit, can't figure out why this is. Here's the respective html:
<div id="main">
<div class="row sort-container">
<span class="sort-by brandon-grotesque-regular">
Lihat berdasarkan:
</span>
<ul class="arvo-regular clearfix">
<li><a class="" href="?sort=popular">Barang Terpopuler</a></li>
<li><a class="" href="?sort=terbaru">Barang Terbaru</a></li>
</ul>
</div>
</div>
You can set vertical-align to middle on the ul element.
However, why do you need a layout so complex? It would be better if every element was inline, with no floated or inline-block box.
This is due to browser defaults, just like body element also has a padding...so we often use something like normalize to reset all of those in all browsers to 0.
ul{
margin:0;
padding:0;
}
And remove margin-left from #main .sort-container li {...
Thats it

CSS - Help me style this menu without using margins?

I'm creating a site where I've encountered a huge IE lag when hovering over the menus.
I'm using Cufon in combination and it seems like it's causing a huge lag when I apply height, width, margins or paddings to the li:hover element.
So, I need to figure out a smart way of doing this otherwise.
The site is here, http://w3box.com/mat
You can clearly see the menu I guess.
So, what I want is to push the entire menu downwards so it's like 3 or 4 pixels above the bottom of the height line. So it matches about the same vertical position as the logo font to the left.
Then, I want the hover effect to be larger in height. Hard to explain, but when hovering over a menu item, imagine a box where the text is positioned at the very bottom of the box. Like this;
http://img710.imageshack.us/img710/2791/menuheader.jpg
Now, you may notice the arrow looking thingy sticking at the bottom. I don't really need that, but if you have any idea on how to do it, I'd appreciate the help! ;)
I have not tried, but I think this may be an option.
You have everything with in one div, why dont you try to put div with in divs?
this is your current code for header.
<div id="header">
<img class="LogoChef" src="img/LogoKokk2.png" alt="Logo"/>
<img class="LogoMatkalender" src="img/MatkalenderLogo.png" alt="Logo"/>
<ul class="menuwrapper">
<li><h4>Logg ut</h4></li>
<li><h4>Kontakt</h4></li>
<li><h4>Kontrollpanel</h4></li>
<li><h4>Oppskrifter</h4></li>
<li><h4>Hjem</h4></li>
</ul>
</div>
You can try something like this, so you have more control over the different objects.
<div id="header" style="float:left;vertical-align:bottom">
<div id="imgChef">
<img class="LogoChef" src="img/LogoKokk2.png" alt="Logo"/>
</div>
<div id="imgMat" style="float:left;vertical-align:bottom">
<img class="LogoMatkalender" src="img/MatkalenderLogo.png" alt="Logo"/>
</div
<div id="menu" style="float:right;vertical-align:bottom">
<ul class="menuwrapper">
<li><h4>Logg ut</h4></li> <li><h4>Kontakt</h4></li>
<li><h4>Kontrollpanel</h4></li>
<li><h4>Oppskrifter</h4></li>
<li><h4>Hjem</h4></li>
</ul>
</div>
</div>
I am not sure that may be the right combination, but I think with the three divs inside the div you will gain more control over the elements inside the header div.
Omit the h4 in the menu since i think it is not needed. Than set display:block on <a> and use line-height and padding-left , padding-right to make the anchor expand the right size. Also notice that li:hover is not supported in IE6/7 without some tweaks. To position the menu on same level as logo just set a margin-top on ul element.
There're too many rules for me, too many useless rules.
Don't have the time to correct all and test it on FF/IE, but this works ofr example :
.menuwrapper li {
float:right;
list-style: none;
padding: 30px 23px 3px 23px;
position: relative;
top: 7px;
}
What about vertical-align?