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
Related
I've been following this tutorial:
http://www.mrc-productivity.com/techblog/?p=1049
I want to make a single item in the navigation bar float to the right, but simply adding float:right; to that particular item didn't do anything. In fact, changing the float:left to float:right only reversed the ordering of the navigation bar items.
Here's a snippet:
#CHARSET "UTF-8";
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#wrap {
width: 100%;
height: 50px;
margin: 0;
z-index: 99;
position: relative;
background-color: #366b82;
}
.navbar {
height: 50px;
padding: 0;
margin: 0;
position: absolute;
border-right: 1px solid #54879d;
}
.navbar li {
height: auto;
width: 150px;
float: left;
text-align: center;
list-style: none;
font: normal bold 12px/1.2em Arial, Verdana, Helvetica;
padding: 0;
margin: 0;
background-color: #366b82;
}
#navright {
float: right;
}
.navbar a {
padding: 18px 0;
border-left: 1px solid #54879d;
border-right: 1px solid #1f5065;
text-decoration: none;
color: white;
display: block;
}
.navbar li:hover, a:hover {
background-color: #54879d;
}
.navbar li ul {
display: none;
height: auto;
margin: 0;
padding: 0;
}
.navbar li:hover ul {
display: block;
}
.navbar li ul li {
background-color: #54879d;
}
.navbar li ul li a {
border-left: 1px solid #1f5065;
border-right: 1px solid #1f5065;
border-top: 1px solid #74a3b7;
border-bottom: 1px solid #1f5065;
}
.navbar li ul li a:hover {
background-color: #366b82;
}
<body>
<div id="wrap">
<ul class="navbar">
<li>Home</li>
<li>Registers
<ul>
<li>People</li>
</ul>
</li>
<li>Operational</li>
<li>Financial</li>
<li>Reports</li>
<li id="navright"><a id="logout" href="/login">Logout</a></li>
</ul>
</div>
</body>
<li id="navright"><a id="logout" href="/login">Logout</a></li>
Just need to get that "Logout" button to be on the right.
Make the containing UL element have a width of 100%
.navbar {
height: 50px;
width: 100%;
padding: 0;
margin: 0;
position: absolute;
border-right: 1px solid #54879d;
}
https://jsfiddle.net/txve55jn/2/
I have borders on the left and right sides of some items in a list, but I'm getting these white gaps that I don't want, but it's only on the right side which is weird and I haven't been able to figure out what I'm doing wrong.
Any help would be great.
The code:
ul {
padding: 0;
list-style: none;
background: #f2f2f2;
}
ul li {
display: inline-block;
position: relative;
line-height: 21px;
width: 150px;
border: 1px solid white;
background: white;
}
ul li:hover {
border: 1px solid black;
}
ul li:hover ul.dropdown {
display: block;
}
ul li:hover li {
border-left: 1px solid black;
border-right: 1px solid black;
}
ul li:hover li.top {
border-top: 1px solid black;
}
ul li:hover li.bottom {
border-bottom: 1px solid black;
}
ul li a {
display: block;
padding: 8px 25px;
color: #333;
text-decoration: none;
}
ul li a:hover {
color: #fff;
background: #939393;
}
ul li ul.dropdown {
font-size: 14px;
width: 150px;
background: #f2f2f2;
display: none;
position: absolute;
z-index: 999;
left: -1px;
}
<ul style="font-size: 16px; width: 500px; margin-left: auto; margin-right: auto; margin-bottom: 0px; margin-top: 4px;">
<li><u>Products</u>
<ul class="dropdown">
<li class="top">Apples
</li>
<li>Cans
</li>
<li>Bowls
</li>
<li class="bottom">Cups
</li>
</ul>
</li>
</ul>
The style in ul li
border: 1px solid white;
is causing extra white lines to be drawn
Remove it and you should be good
I need your help,
How can the css markup below be modified such that the added extra 1 pixel the active clicked on tab to disappear and be removed from my UL LI Tabbed Menu as seen below?
Here is pic of the problem:
HTML Markup:
<div class="container">
<ul class="tabs">
<li>Gallery</li>
<li>Submit</li>
<li>Resources</li>
<li>Contact</li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content">Tab 1 Content</div>
<div id="tab2" class="tab_content">Tab 2 Content</div>
<div id="tab3" class="tab_content">Tab 3 Content</div>
<div id="tab4" class="tab_content">Tab 4 Content</div>
</div>
</div>
CSS:
.container {width: 500px; margin: 10px auto;}
ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
border-bottom: 1px solid #999;
border-left: 1px solid #999;
width: 100%;
height: 31px;
}
ul.tabs li {
float: left;
margin: 0;
padding: 0;
height: 30px;
line-height: 30px;
border: 1px solid #999;
border-left: none;
margin-bottom: 0px;
background: #e0e0e0;
overflow: hidden;
position: relative;
}
ul.tabs li a {
text-decoration: none;
color: #000;
display: block;
font-size: 1.2em;
padding: 0 20px;
outline: none;
}
ul.tabs li a:hover {
background: #ccc;
}
html ul.tabs li.active {
background: #fff;
border-top: 2px solid rgb(230,139,44);
border-bottom: 1px solid #FFF;
}
html ul.tabs li.active a:hover {
background: #fff;
}
.tab_container {
border: 1px solid #999;
border-top: none;
clear: both;
float: left;
width: 100%;
background: #fff;
}
.tab_content {
padding: 20px;
font-size: 1.2em;
}
.tab_content h2 {
font-weight: normal;
padding-bottom: 10px;
font-size: 1.8em;
}
.tab_content h3 a{
color: #254588;
}
These two lines (added at the bottom) fixed it:
ul.tabs {
border-bottom: none;
}
/* Why are you using `html` here? No point to it! */
html ul.tabs li.active {
border-bottom: none;
}
You don't need a full border below your tabs to draw the lines, let your li elements take care of that, and then just shift the 1px border from the bottom to the top by adding it to the border-top. When not using box-sizing: border-box you have to make sure that your borders all add up to the same amount to prevent things like this from happening.
.container {width: 500px; margin: 10px auto;}
ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
border-bottom: 1px solid #999;
border-left: 1px solid #999;
width: 100%;
height: 31px;
}
ul.tabs li {
float: left;
margin: 0;
padding: 0;
height: 30px;
line-height: 30px;
border: 1px solid #999;
border-left: none;
margin-bottom: 0px;
background: #e0e0e0;
overflow: hidden;
position: relative;
}
ul.tabs li a {
text-decoration: none;
color: #000;
display: block;
font-size: 1.2em;
padding: 0 20px;
outline: none;
}
ul.tabs li a:hover {
background: #ccc;
}
html ul.tabs li.active {
background: #fff;
border-top: 2px solid rgb(230,139,44);
border-bottom: 1px solid #FFF;
}
html ul.tabs li.active a:hover {
background: #fff;
}
.tab_container {
border: 1px solid #999;
border-top: none;
clear: both;
float: left;
width: 100%;
background: #fff;
}
.tab_content {
padding: 20px;
font-size: 1.2em;
}
.tab_content h2 {
font-weight: normal;
padding-bottom: 10px;
font-size: 1.8em;
}
.tab_content h3 a{
color: #254588;
}
ul.tabs { border-bottom: none; }
html ul.tabs li.active { border-bottom: none; }
<div class="container">
<ul class="tabs">
<li class="active">Gallery</li>
<li>Submit</li>
<li>Resources</li>
<li>Contact</li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content">Tab 1 Content</div>
<div id="tab2" class="tab_content">Tab 2 Content</div>
<div id="tab3" class="tab_content">Tab 3 Content</div>
<div id="tab4" class="tab_content">Tab 4 Content</div>
</div>
</div>
You could shift the content up a pixel:
html ul.tabs li.active a {
position:relative;
top:-1px;
}
https://jsfiddle.net/7adfsmdj/
change the height as 30px in ul.tabs
since you gave as 30px in ul.tabs li
ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
border-bottom: 1px solid #999;
border-left: 1px solid #999;
width: 100%;
height: **30px;**
}
ul.tabs li {
float: left;
margin: 0;
padding: 0;
height: **30px;**
line-height: 30px;
border: 1px solid #999;
border-left: none;
margin-bottom: 0px;
background: #e0e0e0;
overflow: hidden;
position: relative;
}
Check out the JSfiddle showing what I am up to: http://jsfiddle.net/Amp3rsand/FPj3s/1/
HTML:
<ul id="navigation">
<li>BLAH</li>
<li>MORE <br /> BLAH</li>
<li>STILL <br /> MORE</li>
<li>YADDA <br /> YADDA</li>
<li>ETC ETC <br /> ETC ETC</li>
<li>FINISH</li>
</ul>
CSS:
body {
font-size: 12px;}
}
#navigation {
width: 600px;
height: 50px;
position: absolute;
left: 20px;
top: 25px;
}
#navigation li {
list-style-type:none;
width: 94px;
height: 40px;
display: block;
float: left;
margin: 0 5px 0 0;
text-align: center;
font-weight: bold;
background: lightgrey;
}
#navigation li:first-child {
border-top: 40px solid lightgrey;
border-left: 25px solid transparent;
height: 0;
width: 70px;
background: none;
}
#navigation li:first-child a {
position: relative;
top: -35px;
right: 0px
}
#navigation li:last-child {
border-top: 40px solid lightgrey;
border-right: 25px solid transparent;
height: 0;
width: 70px;
background: none;
}
#navigation li:last-child a {
position: relative;
top: -35px;
left: 5px;
}
#navigation li:last-child a:hover {
top: -35px;
left: 5px;
}
#navigation li a {
display: block;
height: 40px;
text-decoration: none;
color:#000;
}
#navigation li a:hover {
background: grey;
}
The lightgrey shapes are what I would like the hover to look like. Only the first and last children need to look different but I am unsure of how to go about messing with the borders on hover without ruining the layout. I have had to move the first and last 'a' elements because of the border shenanigans and now I'm stuck.
What would you suggest?
EDIT:
I just realised I could do this to change the shape of the hover bit but the link position is still causing trouble
#navigation li:last-child a:hover {
border-top: 40px solid grey;
border-right: 25px solid transparent;
height: 0;
width: 70px;
background: none;
}
See it live here on JS Fiddle
The properties you want to change are of the <li> elements so target the list items hover state and change the background and border color
#navigation li:hover {
background: grey;
}
#navigation li:first-child:hover,
#navigation li:last-child:hover{
background: none;
border-top-color: grey;
}
Updated fiddle
Essentially, you want to set the 'border-top' to grey for the first/ last child.
You could use in CSS:
#navigation li:first-child:hover {
border-top: 40px solid lightgrey;
}
But this didn't work in Google Chrome, for me, so perhaps just apply that as a hover effect using jQuery?
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