cant move ul.width to width:0px - css

I have the following code:
<div class="filter">
<ul>
<span class="filter-icon text-gray-lightest"> <!-- svg-inline--fa -->
<svg xmlns="http://www.w3.org/2000/svg" class="" viewBox="0 0 24 24" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><polyline points="15 6 9 12 15 18"></polyline></svg>
</span>
<li data-filter="f0">Alle</li>
<li data-filter="f1">Verw/Fin</li>
<li data-filter="f2">MaPa</li>
<li data-filter="f3">Presse</li>
<li data-filter="f4">Programme</li>
<li data-filter="f5">Inland</li>
<li data-filter="f6">Controlling</li>
</ul>
</div>
with this css:
.filter {
margin: 1px 0 1px 0;
width: 40%;
background-color:red;
overflow:hidden;
}
.filter ul {
padding-left:8px;
}
.filter-icon {
display: inline-block;
fill: currentColor;
stroke: currentColor;
vertical-align: middle;
transition: transform .5s;
height:16px; width:16px;
}
.filter-icon:hover {
fill: var(--orange);
stroke: #000;
transform:rotate(180deg);
}
.filter ul li {
display:inline-block;
padding:15px;
position:relative;
}
.filter:hover {
width:50px;
}
I would like to change the width of the div.filter with javascript to 0px.
for better test i made here a filter:hover to 50px.
Please see codepen
My Problem is, that the filter-box gets higher. But I would like that the content of the filter-box disapear (by overflow:hidden).
How to achieve this?

let filter = document.getElementsByClassName("filter")[0];
filter.addEventListener("mouseover", function(){filter.style.display = "none"});
filter.addEventListener("mouseout", function(){filter.style.display = "block"});

Related

Expand svg tab as text expands without stretching the sides

I have tabs with svg background that stretches to the width of the text. Is there a way to edit my svg or css to fix the curvatures on the sides without splitting up the svg to separate elements or using pseudo after/before css? This way while the whole svg stretches the middle part, the sides would remain intact stretching only the middle rectangle element.
This would fix the "Other important specification" tab's stretched sides.
$(document).ready(function(){
$('.nav-tabs li').click(function() {
$(this).siblings('li').removeClass('active');
$(this).addClass('active');
});
});
.product-info .row,
.recipe-info .row {
text-align: left;
margin-left: 5px;
}
.product-info .nav-tabs,
.recipe-info .nav-tabs {
border-bottom: 1px solid #def0f8;
}
.product-info .nav-tabs > li,
.recipe-info .nav-tabs > li {
background-color: transparent;
margin-bottom: 0;
overflow: visible;
width: -webkit-fit-content;
width: -moz-fit-content;
width: fit-content;
}
.product-info .nav-tabs > li > a:hover,
.recipe-info .nav-tabs > li > a:hover {
color: white;
text-decoration: none;
border: 0;
background-color: transparent;
}
.product-info .nav-tabs > li > a,
.recipe-info .nav-tabs > li > a {
border: none;
height: 35px;
background-color: transparent;
padding: 0;
text-align: center;
margin-top: 1px;
z-index: 2;
}
.product-info .nav-tabs > li > a .tabbed,
.recipe-info .nav-tabs > li > a .tabbed {
margin: 0;
height: 35px;
width: auto;
}
.product-info .nav-tabs > li > a .tabbed span,
.recipe-info .nav-tabs > li > a .tabbed span {
font-family: Roboto;
font-weight: 500;
font-size: 16px;
color: #616161;
line-height: 35px;
letter-spacing: 0.01em;
background-color: transparent;
padding: 0;
display: inline;
white-space: nowrap;
min-width: 95px;
}
.product-info .nav-tabs > li.active > a,
.recipe-info .nav-tabs > li.active > a {
color: #ffffff;
z-index: 10;
}
.product-info .nav-tabs > li.active > a .tabbed,
.recipe-info .nav-tabs > li.active > a .tabbed {
background-image: url("data:image/svg+xml,%3Csvg xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:cc='http://creativecommons.org/ns%23' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='0 0 134.5 35' preserveAspectRatio='none' data-name='Layer 1' id='Layer_1'%3E%3Cmetadata id='metadata15'%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:format%3Eimage/svg+xml%3C/dc:format%3E%3Cdc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage' /%3E%3Cdc:title%3Etab%3C/dc:title%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cdefs id='defs3'%3E%3Cstyle id='style5'%3E.cls-1%7Bfill:%2325437f;%7D%3C/style%3E%3C/defs%3E%3Ctitle id='title7'%3Etab%3C/title%3E%3Cpath style='fill:%2325437f;fill-opacity:1' id='path9' transform='translate%280 0%29' d='M0,35H30V0C6.39,0,11.8,35,0,35Z' class='cls-1' /%3E%3Cpath style='fill:%2325437f;fill-opacity:1' id='path11' transform='translate%280 0%29' d='M134.5,35h-30V0C128.11,0,122.7,35,134.5,35Z' class='cls-1' /%3E%3Crect y='-5.5511151e-17' x='29.5' height='35' width='56.5%25' id='rect4143' style='opacity:1;fill:%2325437f;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1' /%3E%3C/svg%3E");
background-repeat: no-repeat;
background-size: 100% 35px;
background-position: center;
}
.product-info .nav-tabs > li.active > a .tabbed span,
.recipe-info .nav-tabs > li.active > a .tabbed span {
color: #ffffff;
width: 100%;
margin: 0 35px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel='stylesheet'>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="product-info tabbable">
<div class="row">
<ul class="nav nav-tabs">
<li class="active">
<a href="#" data-toggle="tab">
<div class="tabbed">
<span class="">Details</span>
</div>
</a>
</li>
<li>
<a href="#" data-toggle="tab">
<div class="tabbed">
<span class="">Other important specification</span>
</div>
</a>
</li>
</ul>
</div>
<div class="row">
<div class="tab-content">
lorem ipsum
</div>
</div>
</div>
Probably nested svg's could solve this, here's a notion of how I imagine achieving the rightly expanding svg:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" width="100%" height="35">
<defs>
<style>
</style>
</defs>
<title>expandable tab</title>
<!--
Whole tab as one path, if possible try to adjust the beizer curves so they
would keep the sides unstreched when image is streched on x axis.
-->
<!--
<path fill="#25437f" d="
m30 0
c-23.5,0 -18,35 -30,35
h30 40 30
c-12,0 -6.5,-35 -30,-35
z"
/>
-->
<!--
The sides should have fixed widths of 30, the middle uses up the available space in between.
-->
<g fill="#25437f">
<svg x="0" width="30" class="container-left">
<path d="m0 35h30v-35c-23.61 0-18.2 35-30 35z" class="path-left" vector-effect="non-scaling-stroke"/>
</svg>
<svg x="29" width="90%" style="overflow: hide;">
<!--
Should have width of 100% shrunken with 30 on the x axis.
Maybe apply a mask?
-->
<rect height="35" width="100%" y="-5.5511e-17"/>
</svg>
<svg x="100%" width="30" class="container-right" transform='translate(-30 0)'>
<!--
Its positioning should be counted from the right to left x="0" starting from right if direction could be set.
Hacking with x="100%" and transform="translate(-30 0)" should be doing the same, but they are not.
-->
<path d="m0 35h-30v-35c23.61 0 18.2 35 30 35z" class="path-right" vector-effect="non-scaling-stroke"/>
</svg>
</g>
</svg>
I'm looking for an implementation that uses pure html/svg/css techniques to adjust the tab size (no javascript adjustments). My goal with this is to replace an html hackery with left, middle and right blocks with one html element thus reducing the chance to mess the tab up, and renders the same way across browsers (from IE11>).
Sticking to my code structure with background-image, related css rules of course is not necessary, there could be even pure svg solutions with <text/> tags just to achieve the expanding tab as the text grows with non-stretching side paths.
Related interesting links:
https://www.sarasoueidan.com/blog/mimic-relative-positioning-in-svg/
https://codepen.io/gionkunz/pen/KDvLj
https://jsfiddle.net/boldewyn/taorj2q6/
Ok I tried changing this for you, and used pure CSS with 3 classes (left, middle, and right) - with different SVG base64 data for each. Still feels a bit hacky, but let me know if this is closer to what you are looking for.
$(document).ready(function(){
$('.nav-tabs li').click(function() {
$(this).siblings('li').removeClass('active');
$(this).addClass('active');
});
});
ul {
display:block;
width: 100%;
}
li {
list-style:none;
}
.tabbed {
display:inline-block;
}
.nav-tabs {
display: inline-flex;
width: 100%;
}
.tab-content {
margin-top:50px;
margin-left:70px;
}
.tabText {
position:relative;
color:white;
display:inline-block;
z-index:10;
padding:10px;
height:35px;
vertical-align:top;
}
.left {
display:inline-block;
margin:0;
padding:0;
height: 35px;
width: 35px;
background-image: url("data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns:cc='http://creativecommons.org/ns' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 30 35' enable-background='new 0 0 30 35' xml:space='preserve'%3E%3Cpath id='left' fill='%2325437F' d='M0,35h30V0C6.4,0,11.8,35,0,35z'/%3E%3C/svg%3E");
background-repeat:no-repeat;
background-size:cover;
}
.middle {
display:inline-block;
margin:0;
padding:0;
background-color: #25437F;
background-image: url("data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns:cc='http://creativecommons.org/ns' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 56.5 35' enable-background='new 0 0 56.5 35' xml:space='preserve'%3E%3Crect id='middle' fill='%2325437F' width='56.5' height='35'/%3E%3C/svg%3E%0A");
background-repeat:no-repeat;
background-size:cover;
width:auto;
height:35px;
margin-left:-6px;
}
.right {
display:inline-block;
margin:0;
padding:0;
height: 35px;
width: 35px;
margin-left:-6px;
background-image: url("data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns:cc='http://creativecommons.org/ns' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 30 35' enable-background='new 0 0 30 35' xml:space='preserve'%3E%3Cpath id='right' fill='%2325437F' d='M30,35H0V0C23.6,0,18.2,35,30,35z'/%3E%3C/svg%3E%0A");
background-repeat:no-repeat;
background-size:cover;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="product-info tabbable">
<div class="row">
<ul class="nav nav-tabs">
<li class="active">
<a href="#" data-toggle="tab">
<div class="tabbed">
<div class="left">
<div class="tabText"></div>
</div>
<div class="middle">
<div class="tabText">Details</div>
</div>
<div class="right">
<div class="tabText"></div>
</div>
</div>
</a>
</li>
<li>
<a href="#" data-toggle="tab">
<div class="tabbed">
<div class="left">
<div class="tabText"></div>
</div>
<div class="middle"><div class="tabText">Other important specification</div></div>
<div class="right">
<div class="tabText"></div>
</div>
</div>
</a>
</li>
</ul>
</div>
<div class="row">
<div class="tab-content">
lorem ipsum
</div>
</div>
</div>

Inline element height inconsistencies between browsers

I have an inline-flex element book-ended by two inline block elements. They are all different heights but I want to align them to their vertical centres.
In webkit this is possible by applying position: relative; top: 53px; to the inline-block elements. However, in firefox this puts the inline blocks way below where I want them.
Removing the top offset I can see that the default position of the elements is completely different in webkit and firefox.
Here's a fiddle: https://jsfiddle.net/ralphonz/p9s1pjtd/29/
Here's my HTML:
<div class="newsletter-navigation" role="navigation">
<div class="arrow prev-arrow">
<svg width="100%" height="100%" viewBox="0 0 20 37" version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path id="Arrow-Right-Icon" d="M18.64 32.359L6.323 18.569 18.64 4.78c.923-1.035.923-2.711 0-3.744-.924-1.035-2.421-1.035-3.344 0L1.356 16.642c-.474.531-.701 1.23-.688 1.927-.013.695.214 1.396.688 1.927l13.94 15.606c.923 1.033 2.42 1.033 3.344 0 .923-1.034.923-2.71 0-3.743z" fill="#6d4272"></path></svg>
</div>
<ul class="nav nav-pills">
<li class="archive-year">2017
<ul class="nav">
<li class="nav-item">Item 1</li>
<li class="nav-item">Item 2</li>
<li class="nav-item">Item 3</li>
<li class="nav-item">Item 4</li>
<li class="nav-item">Item 5</li>
</ul>
</li>
<li class="archive-year">2016
<ul class="nav">
<li class="nav-item">Item 1</li>
<li class="nav-item">Item 2</li>
<li class="nav-item">Item 3</li>
<li class="nav-item">Item 4</li>
<li class="nav-item">Item 5</li>
</ul>
</li>
</ul>
<div class="arrow next-arrow">
<svg width="100%" height="100%" viewBox="0 0 20 37" version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path id="Arrow-Right-Icon" d="M18.64 32.359L6.323 18.569 18.64 4.78c.923-1.035.923-2.711 0-3.744-.924-1.035-2.421-1.035-3.344 0L1.356 16.642c-.474.531-.701 1.23-.688 1.927-.013.695.214 1.396.688 1.927l13.94 15.606c.923 1.033 2.42 1.033 3.344 0 .923-1.034.923-2.71 0-3.743z" fill="#6d4272"></path></svg>
</div>
</div>
and here's my SCSS:
.newsletter-navigation {
width: 100vw;
position: relative;
margin-bottom: 2em;
padding: 0 2em 2em;
background-color: rgb(230,230,230);
.arrow {
display: inline-block;
position: relative;
top: 53px;
width: 19px;
height: 37px;
cursor: pointer;
color: rgb(109,66,114);
}
.prev-arrow {
margin-right: .5em;
}
.next-arrow {
margin-left: .5em;
transform: rotate(180deg);
}
ul.nav {
display: inline-flex;
flex-wrap: nowrap;
width: 100%;
overflow: scroll;
li {
width: 25vw;
margin-right: 1em;
padding: 1em 2em;
background-color: rgb(31,148,195);
border-radius:.5em;
color: #fff;
ul {
padding: 0;
}
}
.nav-item {
text-align: center;
}
.archive-year {
width: auto;
margin: 0;
padding: 0;
background-color: transparent;
color: rgb(128, 128, 128);
}
}
&>ul.nav {
width: 85%;
}
}
How can I get a consistent, cross-browser result and achieve my goal of vertical centre alignment?
Since you’re using flexbox anyway, may as well use it to align your elements vertically.
#container {
align-items: center;
display: flex;
}
.small {
background: #fcc;
}
.big {
background: #ccf;
font-size: 2em;
}
<div id="container">
<span class="small">flexbox</span>
<span class="big">vertical</span>
<span class="small">alignment</span>
</div>
Updated fiddle

Is image mapping the best solution?

I have an image that consists of 5 overlapping rectangles, all of which have its relevant heading on them and must link to its corresponding pages. I have tried uploading the image onto an online image mapping generator which automatically generates the code however, i can only alter the CSS and not the HTML. Would image mapping be the best solution for my problem? or is there any alternative methods i could use which doesn't involve modifying the HTML?
This is my image:
HTML:
<div style="text-align:center; width:406px; margin-left:auto; margin-right:auto;">
<img id="Image-Maps_3201310160406077" src="http://www.image-maps.com/uploaded_files/3201310160406077_home_image.png" usemap="#Image-Maps_3201310160406077" border="0" width="406" height="406" alt="" />
<map id="_Image-Maps_3201310160406077" name="Image-Maps_3201310160406077">
<area shape="rect" coords="72,3,192,43" href="#" alt="" title="" />
<area shape="rect" coords="326,75,401,115" href="#" alt="" title="" />
<area shape="rect" coords="4,290,118,330" href="#" alt="" title="" />
<area shape="rect" coords="241,361,332,401" href="#" alt="" title="" />
<area shape="rect" coords="158,180,249,220" href="#" alt="" title="" />
<area shape="rect" coords="404,404,406,406" href="http://www.image-maps.com/index.php?aff=mapped_users_3201310160406077" alt="Image Map" title="Image Map" />
CSS:
dl.image_map {display:block; width:406px; height:406px; background:url(http://www.image-maps.com/uploaded_files/3201310160406077_home_image.png); position:relative; margin:2px auto 2px auto;}
a.LINK0 {left:72px; top:3px; background:transparent;}
a.LINK0 {display:block; width:122px; height:0; padding-top:42px; overflow:hidden; position:absolute;}
a.LINK0:hover {background:transparent; border:1px dashed black; color:black;}
a.LINK1 {left:326px; top:75px; background:transparent;}
a.LINK1 {display:block; width:77px; height:0; padding-top:42px; overflow:hidden; position:absolute;}
a.LINK1:hover {background:transparent; border:1px dashed black; color:black;}
a.LINK2 {left:4px; top:290px; background:transparent;}
a.LINK2 {display:block; width:116px; height:0; padding-top:42px; overflow:hidden; position:absolute;}
a.LINK2:hover {background:transparent; border:1px dashed black; color:black;}
a.LINK3 {left:241px; top:361px; background:transparent;}
a.LINK3 {display:block; width:93px; height:0; padding-top:42px; overflow:hidden; position:absolute;}
a.LINK3:hover {background:transparent; border:1px dashed black; color:black;}
a.LINK4 {left:158px; top:180px; background:transparent;}
a.LINK4 {display:block; width:93px; height:0; padding-top:42px; overflow:hidden; position:absolute;}
a.LINK4:hover {background:transparent; border:1px dashed black; color:black;}
You can do this with full HTML/CSS if you want, playing with position: absolute, z-index and display: table-cell;
nav {
position: relative;
font-family: Arial;
font-size: 14px;
margin: 20px;
}
nav a {
position: absolute;
top: 0; left: 0;
padding: 10px;
border-radius: 5px;
color: #222;
background: #333;
text-decoration: none;
text-transform: uppercase;
}
nav a:hover {
text-decoration: underline;
}
nav a span {
display: table-cell;
width: 145px; height: 145px;
}
.link-home {
top: 115px; left: 115px;
color: white;
line-height: 145px;
font-size: 24px;
background: #C1272C;
box-shadow: 0 0 10px 0 #333;
z-index: 5;
}
.link-printed-digital-media {
top: 0; left: 65px;
background: rgba(50, 50, 50, .8);
z-index: 4;
}
.link-file-sharing {
top: 70px; left: 185px;
background: rgba(50, 50, 50, .6);
z-index: 3;
}
.link-external-links {
top: 185px; left: 165px;
background: rgba(50, 50, 50, .4);
z-index: 2;
}
.link-stock-management {
top: 165px; left: 0;
background: rgba(50, 50, 50, .2);
z-index: 1;
}
/* size */
.link-printed-digital-media span,
.link-external-links span {
height: 200px;
}
.link-file-sharing span,
.link-stock-management span {
width: 200px;
}
/* align */
.link-home span {
text-align: center;
}
.link-file-sharing span,
.link-external-links span {
text-align: right;
}
.link-external-links span,
.link-stock-management span {
vertical-align: bottom;
}
<nav>
<a href="#" class="link-home">
<span>Home</span>
</a>
<a href="#" class="link-printed-digital-media">
<span>Printed &<br>Digital Media</span>
</a>
<a href="#" class="link-file-sharing">
<span>File<br>Sharing</span>
</a>
<a href="#" class="link-external-links">
<span>External<br>Links</span>
</a>
<a href="#" class="link-stock-management">
<span>Stock<br>Management</span>
</a>
</nav>
Please note <span> are required, as you cannot combine table-cell and absolute positioning on the same element.
If you stack the html elements using a z-index (in CSS) with the right size on the right position, and add hyperlinks with images to it, it should work correctly right?
Check out this example to see how it could work.
<html>
<head>
<style>
/* setup container */
.nav-wrapper
{
position:relative;
width:500px;
height:500px;
background:#f0f0f0;
}
/* on each item */
a.nav-item
{
position:absolute;
width:200px;
height:200px;
}
/* per specific item, note the position and the z-index */
.home {
left: 120;
top: 135;
z-index:5; /*on top*/
background:rgba(250,50,50,.9);
}
.print {
left:80;
top: 30;
z-index:1; /*on bottom*/
background:rgba(60,60,60,.5);
}
.fileshare {
left: 40;
top: 180;
z-index:2;
background:rgba(50,50,50,.5);
}
.stock {
left: 235;
top: 220;
z-index:3;
background:rgba(70,70,70,.5);
}
.links {
left: 240;
top: 50;
z-index:4;
background:rgba(80,80,80,.5);
}
/* for example only */
.nav-item img
{
width:200px;
height:200px;
}
</style>
</head>
<body>
<div class="link-wrapper">
<!-- items over here. note the classes -->
<a href="print.html" class="nav-item print">
<img src="print.png" alt="print" />
</a>
<a href="fileshare.html" class="nav-item fileshare">
<img src="fileshare.png" alt="fileshare" />
</a>
<a href="home.html" class="nav-item home">
<img src="home.png" alt="home"/>
</a>
<a href="stock.html" class="nav-item stock">
<img src="stock.png" alt="stock" />
</a>
<a href="links.html" class="nav-item links">
<img src="links.png" alt="links" />
</a>
</div>
</body>
</html>

CSS ids, classes and layouts

[Currently at: http://www.jsfiddle.net/tqtFg Michael Durrant]
I'm very new to css and I'm trying to create a website with a logo and navigation panel side by side. If you visit the site initially the panel appears out of the 'topcontent', just below and to the right in fact, but if you clicked the logo to go to the same page the panel appears where i'd like it to be!
My Site : http://acews.x10.mx
it seems something is not being intialized when first opened, but I can't tell what. here's my html code;
<div id="topcontent">
<div id="top">
<a href="index.html">
<img src="logo.png">
</a>
<div id="navbar">
<ul id="menubar">
<li class="menuButton">Home</li>
<li class="menuButton"><a href="about.html" >About ACE</a></li>
<li class="menuButton"><a href="login.html" >Customer Login</a></li>
</ul>
</div>
</div>
Here's my css code;
body {
}
/*Content page divider*/
#topcontent {
/* margin: 50px auto; */
height: 170px;
margin-left:auto;
margin-right:auto;
background-image:url('backgroundcolor.png');
}
#top {
height: 170px;
width: 900px;
margin-left:auto;
margin-right:auto;
}
/* MenuBar */
#navbar {
margin-top:60px;
float:right;
}
ul#menubar {
/* margin:20px; */
list-style:none;
margin-left:auto;
margin-right:auto;
padding: 5px 10px 0 10px;
}
ul#menubar li {
display:inline;
font-family: calibri;
font-weight: bold;
margin-left:10px;
}
ul#menubar li a {
text-decoration:none;
text-align:center;
padding:5px 10px;
/* width:100px; */
color:#FFFFFF;
float:left;
font-size:26px;
}
.menuButton a:hover{
background-color:#618E00;
text-decoration: none;
-webkit-border-radius: 5px;
}
add id for link with logo:
<a href="index.html" id="logo">
<img src="logo.png">
</a>
and CSS
#logo {float:left;}
link with logo is like one single line, if you add float to it should be ok.

Why no effect of text-align:center and margin:0 auto on positioned element? see live example

CSS
* {margin:0;padding:0}
/* General styles */
#gallery {
padding: 2em 0;
margin: 0 auto;
width: 840px;
font: small Verdana, sans-serif;
}
#gallery #photo-grid {
width: 100%;
margin: 0;
padding: 1em 0;
list-style: none;
}
#gallery #photo-grid li {
float: left;
margin: 0 10px 10px 0;
background: #def;
color: #333;
padding: 0.5em 1em;
}
#gallery #photo-grid li span.photo-title { bottom:-28px;
font-style:italic;
position:absolute;
width:200px
}
/* Positioning and initial formatting */
#gallery #photo-grid {
padding-left: 20px;
}
#gallery #photo-grid li a {text-decoration:none; width: 200px;
height:200px;display:block;background:red}
#gallery #photo-grid li a img {border:0; display: block;}
HTML
<ul id="photo-grid">
<li class="photo">
<a href="#" class="photo-link">
<img src="http://placehold.it/200x150" class="photo-img" width="200" height="150" >
<span class="photo-title">${photo-title}</span>
</a>
</li>
<li class="photo">
<a href="#" class="photo-link">
<img src="http://placehold.it/150x200" class="photo-img" width="150" height="200">
<span class="photo-title">${photo-title}</span>
</a>
</li>
</ul>
Live example http://jsbin.com/onavo
if i use positioning to keep image and bottom than margin:0 auto or text-align center doesn't work
My question is , I want to keep align vertically bottom and horizontally centered, in red box.
is this what you're trying to achieved?
CSS
#gallery{overflow:hidden; padding:10px;}
#gallery #photo-grid{list-style: none;}
#gallery #photo-grid .photo{position:relative; display:inline;}
#gallery #photo-grid .photo-img{border:none;}
#gallery #photo-grid .photo-title{position:absolute; bottom:4px; left:0; right:4px; background-color:#FF0000; padding:10px 2px 10px 2px; text-align:center;}
HTML
<div id="gallery">
<ul id="photo-grid">
<li class="photo">
<a href="#" class="photo-link">
<img src="http://placehold.it/200x150" class="photo-img" width="200" height="150" >
<span class="photo-title">${photo-title}</span>
</a>
</li>
<li class="photo">
<a href="#" class="photo-link">
<img src="http://placehold.it/150x200" class="photo-img" width="150" height="200">
<span class="photo-title">${photo-title}</span>
</a>
</li>
</ul>
</div>

Resources