All,
Have been banging my head at this for a over an hour and am still clueless how to go about solving this seemingly simple trick:
I want to horizontally center divs in my liquid layout.
Jsfiddle: http://jsfiddle.net/K26TN/
HTML Code:
<div id="menu_bars">
<div id="main_bar">
<ul>
<li id="overview_tab" class="maintabs">
<div id="text_overview_tab">Overview</div>
</li>
<li id="collar_tab" class="maintabs">
<div id="text_collar_tab">Collar/ Neckline</div>
</li>
<li class="maintabs" id="body_tab">
<div id="text_body_tab" >Body</div>
</li>
<li id="sleeves_tab" class="maintabs">
<div id="text_sleeves_tab" >Sleeves</div>
</li>
</ul>
</div>
</div>
CSS CODE:
html {
height: 100%;
}
body#container {
position: relative;
width: 100%
min-width: 1280px;
height: 100%;
min-height: 700px;
background-color: rgba(255,255,255,0.8);
margin: 0 auto;
}
#menu_bars {
position: relative;
width: 90%;
height: 20%;
margin: 0 auto;
}
#main_bar {
float: left;
width: 78%;
height: 100%;
}
#main_bar ul {
float: left;
display: table;
width: 100%;
height: 100%;
border-radius: 6px;
vertical-align: middle;
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.maintabs {
display: table-cell;
width: 25%;
height: 100%;
list-style-type: none;
cursor: pointer;
vertical-align: middle;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(255,255,255)), color-stop(100%,rgb(237,237,237))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgb(255,255,255) 0%,rgb(237,237,237) 100%); /* Chrome10+,Safari5.1+ */
background: linear-gradient(top, rgb(255,255,255) 0%,rgb(237,237,237) 100%); /* W3C */
}
.maintabs:first-child {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px; }
.maintabs:last-child {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
.maintabs div {
display: table-cell;
height: 100%;
color: rgb(125,125,125);
font-size: 0.8em;
text-decoration: none;
text-shadow: 0px 1px 2px rgba(150,150,150,0.4);
-moz-transition: all 0.3s ease-in;
-webkit-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
#overview_tab div{
color: rgb(142,101,143);
text-shadow: 0px 1px 1px rgba(248,248,248,1);
}
.maintabs div:hover {
color: rgb(153,112,154);
text-shadow: 1px 1px 0 rgba(255,255,255,0.95);
}
Related
My first tab longer than second one. In first tab there are links and images with anchor link.The problem is first tab's links are still active although I click on second tab and lays down on my tag cloud, so prevent them to be clickable. I would like to know why links of first tab are still clickable althoug they are not appearing?
fiddle
HTML
<section class="tabs">
<input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
<label for="tab-1" class="tab-label-1">About</label>
<input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" />
<label for="tab-2" class="tab-label-2">Services</label>
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" />
<label for="tab-3" class="tab-label-3">Work</label>
<div class="clear-shadow"></div>
<div class="tab-content">
<div class="content-1">
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
</div>
<div class="content-2">
<h2>Most Commented</h2>
</div>
</div>
</section>
Link
CSS
.tabs {
position: relative;
margin: 40px auto;
width: 100%;
height: auto;
}
.tabs input {
position: absolute;
z-index: 1000;
width: 100px;
height: 40px;
left: 0px;
top: 0px;
opacity: 0;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
cursor: pointer;
}
.tabs input#tab-2{
left: 100px;
}
.tabs input#tab-3{
left: 220px;
}
.tabs input#tab-4{
left: 340px;
}
.tabs label {
background: #5ba4a4;
background: -moz-linear-gradient(top, #5ba4a4 0%, #4e8c8a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#5ba4a4), color-stop(100%,#4e8c8a));
background: -webkit-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
background: -o-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
background: -ms-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
background: linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
font-size: 15px;
line-height: 40px;
height: 40px;
position: relative;
padding: 0 12px;
float: left;
display: block;
width: 80px;
color: #385c5b;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: bold;
text-align: center;
text-shadow: 1px 1px 1px rgba(255,255,255,0.3);
border-radius: 3px 3px 0 0;
box-shadow: 2px 0 2px rgba(0,0,0,0.1), -2px 0 2px rgba(0,0,0,0.1);
}
.tabs label:after {
content: '';
background: #fff;
position: absolute;
bottom: -2px;
left: 0;
width: 100%;
height: 2px;
display: block;
}
.tabs input:hover + label {
background: #5ba4a4;
}
.tabs label:first-of-type {
z-index: 4;
box-shadow: 2px 0 2px rgba(0,0,0,0.1);
}
.tab-label-2 {
z-index: 3;
}
.tab-label-3 {
z-index: 2;
}
.tabs input:checked + label {
background: #fff;
z-index: 6;
}
.clear-shadow {
clear: both;
}
.tab-content {
background: #fff;
position: relative;
width: 100%;
height: auto;
z-index: 5;
box-shadow: 0 -2px 3px -2px rgba(0,0,0,0.2), 0 2px 2px rgba(0,0,0,0.1);
border-radius: 0 3px 3px 3px;
}
.tab-content div {
position: absolute;
top: 0;
left: 0;
padding: 10px 40px;
z-index: 1;
opacity: 0;
-webkit-display: flex;
display: flex;
-webkit-flex-flow: column;
flex-flow: column;
-webkit-transition: opacity linear 0.1s;
-moz-transition: opacity linear 0.1s;
-o-transition: opacity linear 0.1s;
-ms-transition: opacity linear 0.1s;
transition: opacity linear 0.1s;
}
.tab-content div img { border: 1px solid #903; position: relative;
}
.tabs input.tab-selector-1:checked ~ .tab-content .content-1,
.tabs input.tab-selector-2:checked ~ .tab-content .content-2,
.tabs input.tab-selector-3:checked ~ .tab-content .content-3 {
z-index: 100;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: opacity ease-out 0.2s 0.1s;
-moz-transition: opacity ease-out 0.2s 0.1s;
-o-transition: opacity ease-out 0.2s 0.1s;
-ms-transition: opacity ease-out 0.2s 0.1s;
transition: opacity ease-out 0.2s 0.1s;
position:relative;
}
.tab-content div h2,
.tab-content div h3{
color: #398080;
}
.tab-content div p {
font-size: 14px;
line-height: 22px;
font-style: italic;
text-align: left;
margin: 0;
color: #777;
padding-left: 15px;
font-family: Cambria, Georgia, serif;
border-left: 8px solid rgba(63,148,148, 0.1);
}
.tab-content li {
overflow: hidden;
list-style: none;
border-bottom: 1px solid #f0f0f0;
margin: 0 0 8px;
padding: 0 0 6px;
}
Because opacity:0 does make your div transparent but it is still there. Change opacity:0 to display:none insteed
fiddle
I'm trying to replicate the navigation buttons here, that's a wix website so it's so hard to inspect elements.
What I have tried is here
https://jsfiddle.net/1vngy4uo/1/
I'm trying many variations, never getting the css 100% correct.
.navButton {
width:15%;
display:inline-block;
position:relative;
background-color:#03314b;
border-radius: 30%;
box-shadow: 2px 2px 2px #888888;
}
.navButton:hover {
background-color:#98b7c8;
}
.navButton span {
width:100%;
display:inline-block;
position:absolute;
border-radius: 30%;
box-shadow: 2px 2px 2px #888888;
}
.navButton .bg {
height:50%;
top:0;
background-color:#3a6076 ;
border-radius: 30%;
box-shadow: 2px 2px 2px #888888;
}
.navButton:hover .bg{
background-color:#afcad9;
}
.navButton .text {
position:relative;
text-align:center;
color:#fff;
vertical-align: middle;
align-items: center;
}
.navButton .text:hover {
color:#000000;
}
and html
<a href="contact.html" class="navButton">
<span class="bg"></span>
<span class="text">Contact</span>
A very similar one, using linear-gradient and less HTML markup
jsFiddle
.navButton {
color: white;
text-decoration: none;
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
text-align: center;
padding: 0 30px;
line-height: 30px;
display: inline-block;
position: relative;
border-radius: 20px;
background-image: linear-gradient(#335b71 45%, #03324c 55%);
box-shadow: 0 2px 2px #888888;
transition: color 0.3s, background-image 0.5s, ease-in-out;
}
.navButton:hover {
background-image: linear-gradient(#b1ccda 49%, #96b4c5 51%);
color: #03324c;
}
Contact
I just used a div element to implement the same button that you referred. Is this what you want?
https://jsfiddle.net/9L60y8c6/
<div class="test">
</div>
.test {
cursor: pointer;
background: rgba(4, 53, 81, 1) url(//static.parastorage.com/services/skins/2.1212.0/images/wysiwyg/core/themes/base/shiny1button_bg.png) center center repeat-x;
border-radius: 10px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
transition: background-color 0.4s ease 0s;
position: absolute;
top: 0;
bottom: 0;
left: 5px;
right: 5px;
height: 30px;
width: 115px;
}
Would this be a start? You might want to adjust the colors a little.
Note: One can use linear-gradient, though it won't work on IE9, so I use a pseudo instead
.navButton {
width: 15%;
display: inline-block;
position: relative;
background-color: #03314b;
border-radius: 8px;
box-shadow: 2px 2px 2px #888888;
text-align: center;
text-decoration: none;
color: #fff;
padding: 5px;
transition: all 0.3s;
overflow: hidden;
}
.navButton:before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 50%;
width: 100%;
background-color: #335b71;
transition: all 0.3s;
}
.navButton span {
position: relative;
}
.navButton:hover {
transition: all 0.3s;
background-color: #96b4c5;
color: black;
}
.navButton:hover:before {
transition: all 0.3s;
background-color: #b1ccda;
}
<a href="contact.html" class="navButton">
<span>Contact</span>
</a>
I found a switch I'd like to use http://codepen.io/katmai7/pen/fyzuH . There is a working example at the above link but there are errors in the code and I ran this thru a code checker but wasn't able to figure out how to fix it. Do you know how to fix it? Here is what the code checker said:
Sorry! We found the following errors (6)
URI : TextArea
27 .wrap Parse Error .line{ position: absolute; top: 50px; width: 100%; border-top: 1px solid #1B1B1C; border-bottom: 1px solid #323334; }
28 .wrap Parse Error }
43 .switch Property user-select doesn't exist : none
45 .switch Lexical error at line 45, column 3. Encountered: "&" (38), after : "" &
48 :hover Parse Error .slide:after{ opacity: .05; }
49 :hover Parse Error Lexical error at line 51, column 3. Encountered: "&" (38), after : ""
html{
height: 100%;
}
body{
height: 100%;
background: #C1D1DA;
background: radial-gradient(ellipse at center, rgba(92,93,95,1) 0%,rgba(47,48,49,1) 100%);
}
.wrap{
position:relative;
margin: 100px auto;
width: 90px;
height: 100px;
border: 1px solid #1F1F20;
border-radius: 5px;
background: linear-gradient(to bottom, rgba(58,59,60,1) 0%,rgba(28,28,29,1) 100%);
box-shadow:inset 0 3px 4px -2px rgba(94,96,96, 1), 0 0 6px -1px rgba(0,0,0, .8), 0 2px 7px -1px rgba(0,0,0, .5);
.line{
position: absolute;
top: 50px;
width: 100%;
border-top: 1px solid #1B1B1C;
border-bottom: 1px solid #323334;
}
}
.switch{
position: relative;
display: block;
margin: 13px 17px;
width: 55px;
height: 25px;
border: 1px solid #1A1A1B;
border-radius: 20px;
background: linear-gradient(to bottom, rgba(31,31,32,1) 0%,rgba(58,58,58,1) 100%);
box-shadow: 0 1px 1px 0 rgba(130,132,134, .6), inset 0 4px 0 -3px rgba(0,0,0, .3);
cursor: pointer;
transition: box-shadow .5s ease .27s, border-color .5s ease .27s;
user-select: none;
&:hover{
.slide:after{
opacity: .05;
}
}
&.p2{
margin-top: 25px;
}
&:after{
display: block;
width: 100%;
height: 100%;
border-radius: 20px;
background: green;
background: linear-gradient(to bottom, rgba(186,101,82,1) 0%,rgba(215,151,101,1) 100%);background: linear-gradient(to bottom, rgba(186,101,82,1) 0%,rgba(215,151,101,1) 100%);
content: "";
opacity: 0;
transition: opacity .5s ease .27s;
}
/some context/
&:before{
position: absolute;
display: block;
width: 95%;
height: 60%;
border-radius: 20px;
background: #fff;
content: "";
opacity: .03;
}
.icon-off, .icon-eye-open{
position: absolute;
z-index: 2;
display: block;
line-height: 25px;
font-size: 18px;
}
.icon-eye-open{
left: 5px;
color: #EDD6CD;
text-shadow: 0 1px 0 #97614B;
}
.icon-off{
top: 1px;
right: 5px;
color: #6D6F70;
}
.slide{
position: absolute;
top: -1px;
left: -2px;
z-index:5;
width: 25px;
height: 25px;
border: 1px solid #171718;
border-radius: 50%;
background: linear-gradient(to bottom, rgba(64,65,66,1) 0%,rgba(30,30,31,1) 100%);
box-shadow:inset 0 1px 2px 0 rgba(93,94,95, .8), 1px 3px 5px -2px rgba(0,0,0, .7);
transition: left .4s ease-in, border-color .4s ease-in .1s;
&:after{
display: block;
width: 100%;
height: 100%;
border-radius: 50%;
background: linear-gradient(to bottom, rgba(243,232,223,1) 0%,rgba(204,169,140,1) 100%);
content: "";
opacity: 0;
transition: opacity .4s ease .1s;
}
}
}
input[type=checkbox]{
display: none;
&:checked{
+ .switch{
border-color: #4D2318;
box-shadow: 0 1px 1px 0 rgba(130,132,134, .6), inset 0 4px 0 -3px rgba(0,0,0, .3), 0 0 15px 0 rgba(213,147,99, .7);
&:after{
opacity: 1;
}
.slide{
left: 29px;
border-color: #704F3F;
&:after{
opacity: 1;
}
}
}
}
}
You are using a CSS parser on LESS syntax, which will definitely throw errors.
LESS allows for selector nesting like this:
.wrap {
/* some css */
.line {
/* some more CSS */
}
}
You can't do this in pure CSS, which is why your CSS checker is throwing all these errors. The code is basically equivalent to:
.wrap { ... }
.wrap .line { ... }
I'm a web designer enthusiast and I've been facing some coding problems in a project I'm currently working on. My goal here is to reproduce the menu styling from this web page: http://blueowlcreative.com/wp/aqua/. I want it to be full-width and centered. This is what I've done so far:
This is the html:
<!-- Menu -->
<div id="menu">
<ul id="menu-bar">
<li>Home</li>
<li>Empresa
<ul>
<li>Nossa história</li>
<li>Sustentabilidade</li>
<li>Compromisso social</li>
</ul>
</li>
<li>Produtos</li>
<li>Cotação</li>
<li>Qualidade
<ul>
<li>Política da qualidade</li>
<li>Certificados</li>
</ul>
</li>
<li>Parceiros
<ul>
<li>Clientes</li>
<li>Fornecedores</li>
</ul>
</li>
<li>Contato</li>
</div><!-- end menu -->
And this is the CSS:
#menu {
width: 100%;
margin: 0;
padding: 0;
height: 60px;
line-height: 100%;
background: #494949;
background: linear-gradient(top, #494949, #353535);
background: -ms-linear-gradient(top, #494949, #353535);
background: -webkit-gradient(linear, left top, left bottom, from(#494949), to(#353535));
background: -moz-linear-gradient(top, #494949, #353535);
border: solid 0px #6d6d6d;
position:relative;
z-index:999; }
#menu-bar {
width: 937px;
margin: 0 auto;
height: 60px;
line-height: 100%; }
#menu-bar li {
margin: 0;
padding: 0;
float: left;
position: relative;
list-style: none; }
#menu-bar a {
margin: 0;
padding: 0px 20px 0px 20px;
font-family: Open Sans;
font-weight: normal;
font-size: 14px;
color: #fff;
text-decoration: none;
display: block;
line-height: 60px;
text-shadow: 1px 1px 0px #000000; }
#menu-bar li ul li a {
margin: 0;
line-height: 20px; }
#menu-bar li:hover > a {
background: #555757;
color: #fff;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
transition: all 0.2s linear; }
#menu-bar ul a:hover {
background: #0399d4;
color: #fff;
text-shadow: 1px 1px 0px #000; }
#menu-bar ul {
display: none;
margin: 0;
padding: 0;
width: 185px;
position: absolute;
top: 60px;
left: 0;
background: #4f5152;
background-image: -moz-linear-gradient(#58595a,#414344);
background-image: -o-linear-gradient(#58595a,#414344);
background-image: -webkit-linear-gradient(#58595a,#414344);
background-image: linear-gradient(#58595a,#414344);
border: 1px solid #212223;
border-top: 1px solid #212223;
-moz-border-radius: 0px 0px 4px 4px;
-webkit-border-radius: 0px 0px 4px 4px;
-khtml-border-radius: 0px 0px 4px 4px;
border-radius: 0 0 4px 4px;
box-shadow: inset 0 3px 0 #45494b; }
#menu-bar li:hover > ul {
display: block; }
#menu-bar ul li {
float: none;
margin: 0;
padding: 0; }
#menu-bar ul a {
padding: 15px 0px 15px 15px;
color:#fff;
text-shadow: 1px 1px 0px #000000; }
#menu-bar ul li:last-child > a {
border-bottom-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
border-bottom-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px; }
#menu-bar:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0; }
#menu-bar {
display: inline-block; }
html[xmlns] #menu-bar {
display: block; }
* html #menu-bar {
height: 1%; }
first you should close your </ul> tag.
and then you should add some styles in your #menu.
top: 0;
left: 0;
change your position:relative; to position:fixed;
#menu {
width: 100%;
margin: 0;
padding: 0;
top: 0;
left: 0;
height: 60px;
line-height: 100%;
background: #494949;
background: linear-gradient(top, #494949, #353535);
background: -ms-linear-gradient(top, #494949, #353535);
background: -webkit-gradient(linear, left top, left bottom, from(#494949), to(#353535));
background: -moz-linear-gradient(top, #494949, #353535);
border: solid 0px #6d6d6d;
position:fixed;
z-index:999;
}
add float: right; in your #menu-bar
#menu-bar {
width: 937px;
margin: 0 auto;
height: 60px;
line-height: 100%;
float: right;
}
All,
I am trying to build a top menu. For some reason, the li elements are not starting from the top of ul, there appears to be a small margin left at the top. Any explanation please.
jsfiddle: http://jsfiddle.net/K26TN/
HTML Code:
<div id="menu_bars">
<div id="main_bar">
<ul>
<li id="overview_tab" class="maintabs"><a id="text_overview_tab">Overview</a></li><li id="collar_tab" class="maintabs"><a id="text_collar_tab">Collar/ Neckline</a></li><li class="maintabs" id="body_tab"><a id="text_body_tab" >Body</a></li><li id="sleeves_tab" class="maintabs"><a id="text_sleeves_tab" >Sleeves</a></li>
</ul>
</div>
</div>
CSS CODE:
html {
height: 100%;
}
body#container {
position: relative;
width: 100%
min-width: 1280px;
height: 100%;
min-height: 700px;
background-color: rgba(255,255,255,0.8);
margin: 0 auto;
}
#menu_bars {
position: relative;
width: 90%;
height: 20%;
margin: 0 auto;
}
#main_bar {
float: left;
width: 78%;
height: 100%;
}
#main_bar ul {
float: left;
width: 100%;
height: 100%;
border-radius: 6px;
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.maintabs {
display: inline-block;
width: 25%;
height: 100%;
list-style-type: none;
cursor: pointer;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(255,255,255)), color-stop(100%,rgb(237,237,237))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgb(255,255,255) 0%,rgb(237,237,237) 100%); /* Chrome10+,Safari5.1+ */
background: linear-gradient(top, rgb(255,255,255) 0%,rgb(237,237,237) 100%); /* W3C */
}
.maintabs:first-child {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px; }
.maintabs:last-child {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
.maintabs a {
display: block;
height: 100%;
color: rgb(125,125,125);
line-height: 100%;
font-size: 0.8em;
text-decoration: none;
text-align: center;
text-shadow: 0px 1px 2px rgba(150,150,150,0.4);
-moz-transition: all 0.3s ease-in;
-webkit-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
#overview_tab a{
color: rgb(142,101,143);
text-shadow: 0px 1px 1px rgba(248,248,248,1);
}
.maintabs a:hover {
color: rgb(153,112,154);
text-shadow: 1px 1px 0 rgba(255,255,255,0.95);
}
Your <li> elements are set to display: inline-block, but their vertical-align property defaults to baseline. Specify this in your CSS:
#main_bar li {vertical-align: top}