How to highlight entire area of list item using :hover - html

When hovering over a list item, see Fiddle (https://jsfiddle.net/22upj1yc/), I want the black highlight to cover not the entire area of the list item, not leaving any white space on top or bottom. Right now it only covers the center area of the list item.
I have tried removing the padding from ul and adding a height to li like this, but it does not work. How do I do this?
ul {
display: inline-block;
list-style: none;
margin: 0 auto;
background: #fff;
border-bottom: 2px solid #d8d8d8;
}
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
height: 50px;
}

Add the hover to the <li> instead of the <a> tag, see fiddle https://jsfiddle.net/22upj1yc/1/
ul li:hover {
background-color: black;
}

I basically have updated your item, look in this jsfiddle.
Instead of just ul { }, I have made it ul li { }.
CODE
body {
font: 15px/1.625em "Helvetica Neue", Helvetica, sans-serif;
background: #f5f5f5;
}
ul li {
display: inline-block;
list-style: none;
padding: 10px;
margin: auto;
background: #fff;
border-bottom: 2px solid #d8d8d8;
}
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
}
ul li a {
color: #777;
text-decoration: none;
padding: 0 12px;
}
ul li:hover {
background-color: black;
}
ul li.next {
border-right: 0;
}
ul li.next:after {
content: "\f054";
font-family: FontAwesome;
font-size: 12px;
padding: 0 10px;
}
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li class="next">
Next
</li>
</ul>

Remove padding top and bottom from ul
ul {
display: inline-block;
list-style: none;
padding: 0 10px;
margin: 0 auto;
background: #fff;
border-bottom: 2px solid #d8d8d8;
}
And add padding to li
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
padding:10px 0px;
}
here is link for jsfiddle https://jsfiddle.net/22upj1yc/6/
!--Sorry for bad English--!

The inline-block elements are adding around 4px space after each element (changes by browser). You can negate this with font-size: 0 on that element and switch your font size to apply directly to the li or a tags.
css
body {
background: #f5f5f5;
// removed font sizing, replaced in ul li below
}
ul {
display: inline-block;
font-size: 0; // get rid of ghost space after inline-blocks
list-style-type: none;
background: #fff;
border-bottom: 2px solid #d8d8d8;
margin: 0; padding: 0;
}
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
text-align: center;
margin: 0;
padding: 0px 6px; // added some left/right padding
font: 15px/1.625em "Helvetica Neue", Helvetica, sans-serif; // moved your font sizing here
}
...there were some other padding issues I believe, basically I set all else to 0.
fiddle
https://jsfiddle.net/Hastig/3ezn15a0/1/

Related

CSS menu moving contents on hover

I'm attempting to create a navigation menu that shows a border when an item is hovered over. While it currently looks fine, the other menu items are pushed out of the way when one item is hovered over. How would I go about making them stay put?
I've tried a few methods that were answered here but none of them have worked.
I've included a fiddle below.
nav {
float: left;
width: 100%;
}
ul {
float: left;
list-style:none;
padding: 0;
position: relative;
left: 50%;
text-align: center;
}
ul li {
display: block;
float: left;
list-style: none;
position: relative;
right: 50%;
margin: 0px 0px 0px 1px;
padding: 5px 40px;
color: white;
line-height: 1.3em;
}
li a:hover {
border: solid 1px black;
padding: 5px 10px;
}
a {
color: black;
font-family: 'Quicksand', sans-serif;
text-decoration: none;
}
<nav>
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>MUSIC</li>
<li>STORE</li>
<li>LIVE</li>
<li>CONTACT</li>
</ul>
</nav>
View on JSFiddle
Because you are adding padding on hover. Move the padding from hover to anchor.
li a:hover {
border: solid 1px black;
}
a {
color: black;
font-family: 'Quicksand', sans-serif;
text-decoration: none;
border: solid 1px transparent;
padding: 5px 10px;
}
Here is the fiddle.
Move the padding property from 'li a: hover' to 'a'.
a {
color: black;
font-family: 'Quicksand', sans-serif;
text-decoration: none;
padding: 5px 10px;
}

CSS bottom border hover "jitter"

I have a navigation bar which I would like to give an orange bottom border when you hover over the navigation buttons. Only problem is that whenever you hover, the border makes the content/navigation buttons "jitter" which they aren't supposed to. Also I already have a black bottom border on the navigation bar at all times so it wont work to change that.
HTML:
<div id="navBarTop">
<ul>
<li>Home</li>
<li>Contact</li>
</ul>
</div>
CSS:
#navBarTop {
padding: 0;
background-image: url('navBarBackground1.png');
border-bottom: 1px solid #4c4c4c;
position: absolute;
bottom: 0;
text-align: center;
left: 0;
right: 0;
}
#navBarTop ul {
list-style: none;
width: 800px;
margin: 0 auto;
padding: 0;
display: inline-block;
}
#navBarTop li {
display: inline-block;
}
#navBarTop li a {
display: block;
padding: 10px 25px;
text-decoration: none;
font-family: "Arial";
color: #ffffff;
}
#navBarTop li a:hover {
border-bottom: 2px solid #FF8000;
}
The jittering seems to be caused by adding the extra 2px border at the bottom when you hover. That causes the text to rise up a bit. To fix this, make sure there's always a 2px border by changing your #navBarTop li a to this:
#navBarTop li a {
display: block;
padding: 10px 25px;
text-decoration: none;
font-family: "Arial";
color: #00ffff;
border-bottom: 2px solid transparent; // <--- add this line
}
That should stabilize things for you.

Using display: block with bottom-border on hover

I want to do my hover like this: http://i.imgur.com/yi3Ehu2.png .
I have done something like this: http://jsfiddle.net/szsq2424/
If I use that hover using botom-border without display: block on anchor elements, ir looks like i want. But when I use display: block on a elements in white header class (to make all the button clickable, not just the text) , it takes that border down to the bottom of the button. Some ideas friends ?? Thanks ! I am new to html + css , appreciate the help !
Wrap the text inside the anchor with a span and apply the border to that.
.white-header {
width: 1400px;
background-color: white;
margin: 0;
padding: 0;
}
.white-header ul {
margin: 0 0 0 100px;
padding: 0;
}
.white-header ul li {
list-style: none;
float: left;
line-height: 60px;
}
.white-header ul li a {
display: block;
text-align: center;
}
.white-header ul li a:link,
.white-header ul li a:visited {
color: #3f3f3f;
text-decoration: none;
}
.white-header ul li a:hover {
color: #57C5A0;
}
.white-header ul li a:hover span {
color: #57C5A0;
border-bottom: 2px solid #57C5A0;
}
/********
FIRST BUTTON
********/
.white-first {
width: 120px;
max-height: 60px;
text-align: center;
border-left: 1px solid #383838;
border-right: 1px solid #383838;
}
/********
SECOND BUTTON
*********/
.white-second {
width: 150px;
text-align: center;
border-right: 1px solid #383838;
margin: 0;
}
.white-second a:link,
.white-second a:visited {
color: black;
text-decoration: none;
}
.white-second a:hover {
color: #57C5A0;
padding-bottom: -10px;
}
/******
VISA LIETUVA BUTTON
*******/
.white-third {
width: 270px;
border-right: 1px solid #383838;
}
<header class="white-header">
<ul>
<li class="white-first"><span>Pramogos</span></li>
<li class="white-second"><span>Pramogos</span></li>
<li class="white-third"><span>Pramogos</span></li>
</ul>
</header>
you can add text-decoration: underline to :hover to achieve result like on provided image

HTML CSS UL menu styling

Small question on how to achieve some styling on a HTML / CSS UL menu.
I have a standard UL menu, but having some issues getting my head around how to achieve a certain look to the styling. The UL menu as it currently stands is shown here:
http://jsfiddle.net/WMQqt/
(HTML)
<ul id="nav">
<li>CONTACT US
</li>
<li>HOME
</li>
</ul>
(CSS)
#nav {
list-style: none;
margin-bottom: 10px;
*/ margin-top: -6px;
position: relative;
right: 286px;
z-index: 9;
height: 26px;
padding: 4px 4px 4px 4px;
font-weight: bold;
}
#nav li {
float: right;
margin-right: 10px;
}
#nav a {
display: block;
padding: 5px;
color: #444444;
background: #fff;
text-decoration: none;
border: 1px solid grey;
}
#nav a:hover {
color: #fff;
background: #04B431;
}
I'd like the menu buttons to have a small 1px border, but then some white space padding of around 3px before the background color starts.
Similar to how this looks:
http://jsfiddle.net/6PY7z/
Can this be done using the UL menu method?
Thanks for any advice, I'm no expert with HTML / CSS.
Add margin to a tag and move border to li
#nav li
{
float: right;
margin-right: 10px;
border: 1px solid grey;
}
#nav a
{
display: block;
padding: 5px;
color: #444444;
background: #ccc;
text-decoration: none;
margin:3px;
}
DEMO
you can use the following styles to achieve what you want:
#nav li
{
float: right;
margin-right: 10px;
border: 1px solid grey; /*put original border here*/
}
#nav a
{
display: block;
padding: 5px;
color: #444444;
background: #d8d8d8; /*new background-color*/
text-decoration: none;
border: 3px solid white; /*add white padding here*/
}
http://jsfiddle.net/WMQqt/4/
ok
in html go
<dl><div><dt>F</dt><dd>T</dd></div>
<div><dt>F</dt><dd>T</dd></div>
<div><dt>F</dt><dd>T</dd></div>
<div><dt>F</dt><dd>T</dd></div>
</dl>
in css
dl { display: flex;
flex-direction: column;}
some hints...
dt float left AND
dd float right

Tabbed Pagination Help

I have built a simple pagination list and styled it using CSS. However, I've run into a problem. Because I want the list elements to be centred on the page, I've used a container div with relative positioning.
Here's an illustration that shows what I have at the moment, and what I would like to achieve:
Notice the seeming lack of a border on the current page number.
Here's the HTML markup for the list:
<div class="pagination-cont">
<ul class="pagination">
<li class="disabled"><span>< Previous</span></li>
<li class="current"><span>1</span></li>
<li>2</li>
<li>3</li>
<li class="separator">…</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>Next ></li>
</ul>
</div>
and here's the CSS:
div#content div.pagination-cont {
float: left;
width: 100%;
overflow: hidden;
position: relative;
margin: 15px 0;
border-top: 1px solid #d1d1d3;
padding-bottom: 2px;
background-color: #e4e4e6;
}
div#content div.pagination-cont ul.pagination {
clear: left;
float: left;
list-style: none;
padding: 0;
margin: 0;
position: relative;
left: 50%;
text-align: center;
}
div#content ul.pagination li {
display: block;
float: left;
list-style: none;
margin: 0;
padding: 0;
position: relative;
right: 50%;
font-size: 110%;
text-transform: uppercase;
font-weight: bold;
}
div#content ul.pagination li.disabled span,
div#content ul.pagination li.separator {
color: #bbb;
text-shadow: 1px 1px 0 #f2f2f2;
padding: 10px 20px;
display: block;
}
div#content ul.pagination li.separator {
border-left: 1px solid #d1d1d3
}
div#content ul.pagination li a {
display: block;
padding: 10px 20px;
color: #004276;
text-decoration: none;
border-left: 1px solid #d1d1d3;
margin-bottom: 1px
}
div#content ul.pagination li.current span {
display: block;
padding: 10px 20px;
border-left: 1px solid #d1d1d3;
background-color: #fff;
color: #999;
border-bottom: 1px solid #d1d1d3
}
Any help would be gratefully received!
You almost have it, just remove "overflow:hidden" from "div.pagination-cont" (that is keeping the selected item from shifting to the top) and add "top:-1px; position:relative;" to: "ul.pagination li.current span", that should do the trick.
You can see it as http://jsfiddle.net/LGwDV/
remove the
border-top: 1px solid #D1D1D3;
from
div#content div.pagination-cont
and write here
div#content ul.pagination li {
border-top: 1px solid #d1d1d3;
}
and also write one line in
div#content ul.pagination li.current {
border-top: medium none;
}
DEMO