How can I fix the hover and transition on my nav menu? - html

I'm building a vertical tabbed navigation menu.
I'm having two problems when I hover over the tabs.
First, only the tab that is hovered is supposed to expand. But what actually happens is multiple tabs expand.
Second, the expand transition is not smooth. It's very jerky and annoying.
I've gone through my code but can't figure it out. What am I missing?
Each tab should expand smoothly and by itself when hovered.
Any feedback would be appreciated.
Live site: http://gearbags.com/store/shop/
HTML:
<!-- First Tab -->
<div id="slideout">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner">
<h4>ACCESSORIES</h4><br />
<h4>LXFB30</h4>
<h4>LXGC-HD</h4>
<h4>LXFGS</h4>
<h4>LXFGS-HD</h4>
<h4>LXMK-A</h4>
<h4>LXMK-B</h4>
<h4>LXMK-C</h4>
<h4>LXMK-D</h4>
<h4>LXMK-E</h4>
</div>
</div>
<!-- Second Tab -->
<div id="slideout-fire">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner_fire">
<h4>FIREFIGHTER</h4><br />
<h4>LXFB30</h4>
<h4>LXGC-HD</h4>
<h4>LXFGS</h4>
<h4>LXFGS-HD</h4>
<h4>LXMK-A</h4>
<h4>LXMK-B</h4>
<h4>LXMK-C</h4>
<h4>LXMK-D</h4>
<h4>LXMK-E</h4>
</div>
</div>
<!-- Third Tab -->
<div id="slideout-medical">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner_medical">
<h4>MEDICAL</h4><br />
<h4>LXMB5-HP</h4>
<h4>LXMB15</h4>
<h4>LXMB20</h4>
<h4>LXMB30</h4>
<h4>LXMB35</h4>
<h4>LXMB40</h4>
<h4>LXMB50</h4>
<h4>LXMB65</h4>
<h4>LXMK-A</h4>
<h4>LXMK-B</h4>
<h4>LXMK-C</h4>
<h4>LXMK-D</h4>
<h4>LXMK-E</h4>
</div>
</div>
<!-- Fourth Tab -->
<div id="slideout-tactical">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner_tactical">
<h4>TACTICAL</h4><br />
<h4>LXPB10</h4>
<h4>LXPB40</h4>
</div>
</div>
CSS
/* ---------- First Tab ---------- */
#slideout {
position: fixed;
top: 40px;
left: -500px;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout img {
position: relative;
left: 75px;
/* margin-left: -860px; */
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner {
position: fixed;
top: 70px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner a {
text-decoration: none;
color: #5a5683;
}
#slideout:hover {
/*left: 320px;*/
/* left: 380px; */
left: -155px;
}
#slideout:hover #slideout_inner {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner a:hover {
color: #FF6824;
}
/* ---------- Second Tab ---------- */
#slideout-fire {
position: fixed;
top: 220px;
left: -500px;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout-fire img {
position: relative;
/* margin-left: -860px; */
left: 75px;
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner_fire {
position: fixed;
top: 250px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner_fire a {
text-decoration: none;
color: #5a5683;
}
#slideout-fire:hover {
/*left: 320px;*/
left: -115px;
}
#slideout-fire:hover #slideout_inner_fire {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner_fire a:hover {
color: #FF6824;
}
/* ---------- Third Tab ---------- */
#slideout-medical {
position: fixed;
top: 400px;
left: -500px;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout-medical img {
position: relative;
/* margin-left: -860px; */
left: 75px;
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner_medical {
position: fixed;
top: 430px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner_medical a {
text-decoration: none;
color: #5a5683;
}
#slideout-medical:hover {
/*left: 320px;*/
left: -115px;
}
#slideout-medical:hover #slideout_inner_medical {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner_medical a:hover {
color: #FF6824;
}
/* ---------- Fourth Tab ---------- */
#slideout-tactical {
position: fixed;
top: 580px;
left: -500px;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout-tactical img {
position: relative;
/* margin-left: -860px; */
left: 75px;
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner_tactical {
position: fixed;
top: 600px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner_tactical a {
text-decoration: none;
color: #5a5683;
}
#slideout-tactical:hover {
/*left: 320px;*/
left: -115px;
}
#slideout-tactical:hover #slideout_inner_tactical {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner_tactical a:hover {
color: #FF6824;
}

It looks like what's causing multiple tabs to expand when only one is hovered is the width: 400px declaration on all four #slideout_inner-... div children of the main tab container (#slideout-...).
This width is covering an area much greater than the tab it belongs to; it's overlapping other tabs. In testing in Chrome, if you just remove this width, the overlapping disappears and the width expands only enough to fill its content.
So, step one: remove width: 400px on all div children referenced above. This seems to fix the hover issue. The transitions are now smooth. BUT the content is now gone from view.
To fix this, you need to adjust the positioning in the same four slideout_inner-... div children.
Try adding margin-left: 175px to each rule.
You may still need to tweak positioning a bit in order to align the text to your preferences. But I think the adjustments above solve both problems raised in your question.
DEMO: http://jsfiddle.net/wf0658ko/1/

Regarding your transition; you are using the transition-duration property without setting an actual transition.
Add this shorthand property to your tabs and it should solve your problem:
transition:all 0.5s ease-in-out;
The function on the side navigation is funky because your transforms maintain 450px of width and are covering the adjacent tabs.
Side note: if you aren't familiar with Chrome Dev Tools, it's a good place to find answers to your problems (like these).

Related

Div border in curve shape

I'm trying to achieve div border in the convex shape and on hover it should be in normal square shape. I have added in the bottom as same I want to add on the top I tried using before but unable to achieve the result. Can anyone help me Below is my code so far I have done.
Any help will be appreciated
* {
box-sizing: border-box;
}
.services {
position: relative;
width: 500px;
height: 420px;
margin: 100px;
background-color: #cccccc;
transition: all 0.2s ease;
animation: down-bump 0.4s ease;
}
.services:before {
}
.serv_section {
top: 83%;
position: relative;
overflow: hidden;
padding: 50px 0 0;
}
.serv_inner {
position: relative;
background: #fff;
height: 25px;
}
.serv_inner:after {
box-shadow: 0 0 0 80px #fff;
border-radius: 100%;
position: absolute;
height: 150px;
content: '';
right: -20%;
left: -20%;
top: -150px;
transition: all 0.4s ease-in-out;
}
.services:hover .serv_inner:after {
top: -120px;
}
.serv_inner:before {
/* box-shadow: 0 0 0 80px #fff;
border-radius: 100%;
position: absolute;
height: 150px;
content: '';
right: -20%;
left: -20%;
top: 130px;
transition: all 0.4s ease-in-out; */
}
span.image_caption {
position: absolute;
color: red;
padding: 10px 20px;
font-size: 30px;
z-index: 10;
animation-duration: 2.5s;
animation-fill-mode: both;
}
span.image_caption p {
font-size: 32px;
font-weight: 900;
font-family: 'Dancing Script', cursive;
color: cadetblue;
}
<div class='services'>
<div class="serv_section">
<div class="serv_inner">
</div>
</div>
</div>
You can use the before and after elements to make the curve, on hover hide the psuedo elements behind the element and remove the curve like this:
.services {
position: relative;
width: 100px;
height: 60px;
margin: 100px;
background-color: #cccccc;
z-index: 0;
}
.services:hover:before{
top: 0px;
border-radius: 0;
}
.services:hover:after{
bottom: 0px;
border-radius: 0;
}
.services:before, .services:after{
content: ' ';
position: absolute;
width: 100%;
height: 40px;
background-color: #cccccc;
border-radius: 50%;
z-index: -1;
transition: all .4s;
}
.services:before {
top: -20px;
}
.services:after {
bottom: -20px;
}
<div class='services'>
</div>
If I understand it right you can achieve this by simple using of different values for horizontal and vertical dimensions of the border-radius property (more info at https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius):
div {
background: grey;
height: 100px;
width: 200px;
transition: border-radius .15s ease-out;
}
/* border-radius on default state */
div {
border: 4px solid black;
border-radius: 50%/20px;
}
div:hover {
border-radius: 0;
}
<div></div>

Positioning the input form in the middle using margin: 0 auto not working

I'm trying to position the input form in the middle of form container using margin: 0 auto;, but not working.
I selected the div container and apply this:
.group {
position: relative;
top: 20px;
margin: 0 auto;
}
body {
background-color: Royalblue; /*#f0f0f0;*/
margin: 0px;
}
form {
position: relative;
top: 90px;
margin: 0 auto;
width: 280px;
height: 340px;
border: 1px solid #B0C4DE;
background: royalblue;
border-radius: 0px;
border-radius: 10px 10px 10px 10px;
}
/* Main EFFECT ================================ */
input {
position: relative;
top: 0px;
left: 0px;
font-family: 'Montserrat', sans-serif;
border: 0;
border-bottom: 1px solid white;
background: transparent;
font-size: 15px;
height: 25px;
width: 180px;
outline: 0;
z-index: 1;
color: black;
}
label {
display: block;
}
span {
position: absolute;
top: 7px;
left: 0px;
font-family: 'Montserrat', sans-serif;
font-size: 13px;
z-index: 1;
color: white;
transition: top .5s ease, font-size .5s ease;
}
.group {
position: relative;
top: 20px;
margin: 0 auto;
}
/*
label::after {
content: '';
position: absolute;
top: 5px;
left: 0px;
width: 200px;
height: 23px;
border-radius: 2px;
background: beige;
transition: transform .7s;
transform: scale3d(1, 0.1, 1);
transform-origin: bottom;
}
*/
/*
input:focus + label::after {
top: 5px;
transform: scale3d(1, 1.2, 1);
transition-timing-function: linear;
}
input:focus + label > span {
top: -20px;
font-size: 10px;
}
*/
<body>
<form>
<div class="group">
<input class="input1" type="email" id="email" required />
<label class="label1" for="email">
<span class="sp1">Email</span>
</label>
</div>
</form>
</body>
without width browser can not calculate how much margins it will put to left/right
you can see here in your case decrease width
http://prntscr.com/kvqscq
body {
background-color: Royalblue; /*#f0f0f0;*/
margin: 0px;
}
form {
position: relative;
top: 90px;
margin: 0 auto;
width: 280px;
height: 340px;
border: 1px solid #B0C4DE;
background: royalblue;
border-radius: 0px;
border-radius: 10px 10px 10px 10px;
}
/* Main EFFECT ================================ */
input {
position: relative;
top: 0px;
left: 0px;
font-family: 'Montserrat', sans-serif;
border: 0;
border-bottom: 1px solid white;
background: transparent;
font-size: 15px;
height: 25px;
width: 180px;
outline: 0;
z-index: 1;
color: black;
}
label {
display: block;
}
span {
position: absolute;
top: 7px;
left: 0px;
font-family: 'Montserrat', sans-serif;
font-size: 13px;
z-index: 1;
color: white;
transition: top .5s ease, font-size .5s ease;
}
.group {
position: relative;
top: 20px;
margin: 0 auto;
width: max-content;
}
/*
label::after {
content: '';
position: absolute;
top: 5px;
left: 0px;
width: 200px;
height: 23px;
border-radius: 2px;
background: beige;
transition: transform .7s;
transform: scale3d(1, 0.1, 1);
transform-origin: bottom;
}
*/
/*
input:focus + label::after {
top: 5px;
transform: scale3d(1, 1.2, 1);
transition-timing-function: linear;
}
input:focus + label > span {
top: -20px;
font-size: 10px;
}
*/
<body>
<form>
<div class="group">
<input class="input1" type="email" id="email" required />
<label class="label1" for="email">
<span class="sp1">Email</span>
</label>
</div>
</form>
</body>
Give your .group class below css, and you're all set...
.group {
width: max-content;
}
Now label will also move into center...
try this
.sp1{
left : 70px;
}

Text not contain inside div

I need to get the text of div with id='form1' and id='form2' to fit inside their respective container. Currently, the number 40 should be inside the white box on the left but for some reason, it got pushed down.I have tried inserting span and div tag inside form1/form2 but it doesn't do anything. I also try word-wrap in CSS and nothing change.
.form1{
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
position: absolute;
}
.form2{
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1{
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat ;
vertical-align:center;
position: absolute;
margin: 30% 20%;
}
#container
{
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before
{
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center ;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s
-o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1{
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
<div id="container">
<div class='form1'>40</div>
<div class="box1"></div>
<div class='form2'></div>
</div>
Here is the jsfiddle to illustrate the code : https://jsfiddle.net/xffc49qL/8/
Your form1 containers line-height is the reason why your text is out of the box. change it to line-height: normal, it should bring back the content within the form1. Also, absolute doesn't have any impact in your case, as the element is float already.
All you need to change is form1 elements line-height.
.form1 {
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
line-height: normal;
}
.form2 {
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1 {
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat;
vertical-align: center;
position: absolute;
margin: 30% 20%;
}
#container {
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before {
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s -o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1 {
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
<div id="container">
<div class='form1'>40</div>
<div class="box1"></div>
<div class='form2'></div>
</div>
use position:absolute to fix your variable on a particular position
#test{
position:absolute;
margin-top:-62px;
margin-left:-10px;
}
.form1{
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
position: absolute;
}
.form2{
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1{
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat ;
vertical-align:center;
position: absolute;
margin: 30% 20%;
}
#container
{
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before
{
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center ;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s
-o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1{
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
<div id="container">
<div class='form1'><div id='text1'><span id="test">40</span></div></div>
<div class="box1"></div>
<div class='form2'></div>
</div>
Add margin-top: -64px; in #test to get it positioned inside the box
.form1{
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
position: absolute;
}
.form2{
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1{
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat ;
vertical-align:center;
position: absolute;
margin: 30% 20%;
}
#container
{
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before
{
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center ;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s
-o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1{
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
#test
{
margin-top: -64px;
}
<div id="container">
<div class='form1'><div id='text1'>40</div></div>
<div class="box1"></div>
<div class='form2'></div>
</div>
Can you explain why you are using line-height? If you remove line-height, the code works. Try it in fiddle. Comment out line-height in #container style. The text '0' will move inside the form1 and form2.

Is there any way to limit the hover region of a property in CSS?

I have created some tabs that slide out upon hover with only CSS and HTML. I am running into some issues with the hover position and sensitivity. I know that I can somewhat combat the sensitivity with the transition speed, but it seems as though when I hover in a space that isn't on the tab, said tab will pop out. Specifically if I attempt to access the price filter or any of the categories in the sidebar. I would like to limit the action to only be invoked once my mouse has hovered over the actual tab. You can see what I am writing about here Is there a way to correct this issue so that I can still access the other elements of the page and have the tabs work properly at the same time?
As a quick note: All of the tabs have the same styling, with the
exception of the positioning, so you can just look at the code
of the first element.
Here is the HTML:
<!-- First Tab -->
<div id="slideout">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner">
<h4>ACCESSORIES</h4><br />
<h4>LXFB30</h4>
<h4>LXGC-HD</h4>
<h4>LXFGS</h4>
<h4>LXFGS-HD</h4>
<h4>LXMK-A</h4>
<h4>LXMK-B</h4>
<h4>LXMK-C</h4>
<h4>LXMK-D</h4>
<h4>LXMK-E</h4>
</div>
</div>
<!-- Second Tab -->
<div id="slideout-fire">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner_fire">
<h4>FIREFIGHTER</h4><br />
<h4>LXFB30</h4>
<h4>LXGC-HD</h4>
<h4>LXFGS</h4>
<h4>LXFGS-HD</h4>
<h4>LXMK-A</h4>
<h4>LXMK-B</h4>
<h4>LXMK-C</h4>
<h4>LXMK-D</h4>
<h4>LXMK-E</h4>
</div>
</div>
<!-- Third Tab -->
<div id="slideout-medical">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner_medical">
<h4>MEDICAL</h4><br />
<h4>LXMB5-HP</h4>
<h4>LXMB15</h4>
<h4>LXMB20</h4>
<h4>LXMB30</h4>
<h4>LXMB35</h4>
<h4>LXMB40</h4>
<h4>LXMB50</h4>
<h4>LXMB65</h4>
<h4>LXMK-A</h4>
<h4>LXMK-B</h4>
<h4>LXMK-C</h4>
<h4>LXMK-D</h4>
<h4>LXMK-E</h4>
</div>
</div>
<!-- Fourth Tab -->
<div id="slideout-tactical">
<img src="http://i.imgur.com/Y4LMQhS.png" alt="tab" />
<div id="slideout_inner_tactical">
<h4>TACTICAL</h4><br />
<h4>LXPB10</h4>
<h4>LXPB40</h4>
</div>
</div>
And this is the CSS:
/* ---------- First Tab ---------- */
#slideout {
position: fixed;
top: 40px;
left: 0;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout img {
position: relative;
margin-left: -860px;
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner {
position: fixed;
top: 70px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner a {
text-decoration: none;
color: #5a5683;
}
#slideout:hover {
/*left: 320px;*/
left: 380px;
}
#slideout:hover #slideout_inner {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner a:hover {
color: #FF6824;
}
/* ---------- Second Tab ---------- */
#slideout-fire {
position: fixed;
top: 220px;
left: 0;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout-fire img {
position: relative;
margin-left: -860px;
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner_fire {
position: fixed;
top: 250px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner_fire a {
text-decoration: none;
color: #5a5683;
}
#slideout-fire:hover {
/*left: 320px;*/
left: 380px;
}
#slideout-fire:hover #slideout_inner_fire {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner_fire a:hover {
color: #FF6824;
}
/* ---------- Third Tab ---------- */
#slideout-medical {
position: fixed;
top: 400px;
left: 0;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout-medical img {
position: relative;
margin-left: -860px;
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner_medical {
position: fixed;
top: 430px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner_medical a {
text-decoration: none;
color: #5a5683;
}
#slideout-medical:hover {
/*left: 320px;*/
left: 380px;
}
#slideout-medical:hover #slideout_inner_medical {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner_medical a:hover {
color: #FF6824;
}
/* ---------- Fourth Tab ---------- */
#slideout-tactical {
position: fixed;
top: 580px;
left: 0;
width: 500px;
height: 140px;
padding: 12px 0;
text-align: center;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-webkit-border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
z-index: 999;
}
#slideout-tactical img {
position: relative;
margin-left: -860px;
width: 500px;
height: 200px;
top: 0;
z-index: 0;
/*
position: relative;
margin-left: -430px;
width: 500px;
height: 200px;
top: -58px;
z-index: 0;*/
}
#slideout_inner_tactical {
position: fixed;
top: 600px;
/*left: -300px;*/
left: -250px;
width: 400px;
padding: 25px;
height: 120px;
line-height: 1.5em;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;
-o-transition-duration: 0.5s;
text-align: center;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-webkit-border-radius: 0 0 5px 0;
-moz-border-radius: 0 0 5px 0;
border-radius: 0 0 5px 0;
z-index: 9999;
}
#slideout_inner_tactical a {
text-decoration: none;
color: #5a5683;
}
#slideout-tactical:hover {
/*left: 320px;*/
left: 380px;
}
#slideout-tactical:hover #slideout_inner_tactical {
/*left: 35px;*/
left: 125px;
}
.vertical-text {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
.gbtitle {
margin: 0px;
padding: 0 100px;
text-decoration: none;
color: #5a5683;
text-align: right;
z-index: 1;
}
.gbtitle a {
text-decoration: none;
color: #5a5683;
}
.gbtitle a:hover {
text-decoration: none;
color: #FF6824;
}
#slideout_inner_tactical a:hover {
color: #FF6824;
}
You have a lot of positioning and negative margins going on in those sliders.
The following solution works in testing in Chrome.
Make the following adjustments to your existing CSS rules:
#slideout { left: -500px; }
#slideout img { left: 75px; } /* AND REMOVE { margin-left: -860px; } */
#slideout:hover { left: -115px; }
... and repeat for three subsequent tabs.
DEMO: http://jsfiddle.net/dxvc08nk/

It can make a modal popup window with just HTML and CSS?

I would be interested to know if you can make a modal pop-up window just using HTML and CSS without JQuery.
Does anyone know such a simple example?
Thanks in advance!
A modal with only HTML and CSS no jQuery or javascript
body {
color: #333333;
font-family: 'Helvetica', arial;
height: 80em;
}
.wrap {
padding: 40px;
text-align: center;
}
hr {
clear: both;
margin-top: 40px;
margin-bottom: 40px;
border: 0;
border-top: 1px solid #aaaaaa;
}
h1 {
font-size: 30px;
margin-bottom: 40px;
}
p {
margin-bottom: 20px;
}
.btn {
background: #428bca;
border: #357ebd solid 1px;
border-radius: 3px;
color: #fff;
display: inline-block;
font-size: 14px;
padding: 8px 15px;
text-decoration: none;
text-align: center;
min-width: 60px;
position: relative;
transition: color .1s ease;
/* top: 40em;*/
}
.btn:hover {
background: #357ebd;
}
.btn.btn-big {
font-size: 18px;
padding: 15px 20px;
min-width: 100px;
}
.btn-close {
color: #aaaaaa;
font-size: 30px;
text-decoration: none;
position: absolute;
right: 5px;
top: 0;
}
.btn-close:hover {
color: #919191;
}
.modal:before {
content: "";
display: none;
background: rgba(0, 0, 0, 0.6);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.modal:target:before {
display: block;
}
.modal:target .modal-dialog {
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
top: 20%;
}
.modal-dialog {
background: #fefefe;
border: #333333 solid 1px;
border-radius: 5px;
margin-left: -200px;
position: fixed;
left: 50%;
top: -100%;
z-index: 11;
width: 360px;
-webkit-transform: translate(0, -500%);
-ms-transform: translate(0, -500%);
transform: translate(0, -500%);
-webkit-transition: -webkit-transform 0.3s ease-out;
-moz-transition: -moz-transform 0.3s ease-out;
-o-transition: -o-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
}
.modal-body {
padding: 20px;
}
.modal-header,
.modal-footer {
padding: 10px 20px;
}
.modal-header {
border-bottom: #eeeeee solid 1px;
}
.modal-header h2 {
font-size: 20px;
}
.modal-footer {
border-top: #eeeeee solid 1px;
text-align: right;
}
/*ADDED TO STOP SCROLLING TO TOP*/
#close {
display: none;
}
<div class="wrap">
<h1>Modal - Pure CSS (no Javascript)</h1>
<hr />
Modal!
</div>
<!-- Modal -->
<div class="modal" id="modal-one" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-header">
<h2>Modal in CSS?</h2>
× <!--CHANGED TO "#close"-->
</div>
<div class="modal-body">
<p>One modal example here! :D</p>
</div>
<div class="modal-footer">
Nice! <!--CHANGED TO "#close"-->
</div>
</div>
</div>
</div>
<!-- /Modal -->
Yes, it is possible.
You can use the :target pseudo selector to show a modal.
Here's an example including some transitions as well (code combined from shehary's codepen example and http://tympanus.net/Development/ModalWindowEffects):
body {
background-color: #e74c3c;
}
a {
background-color: #c0392b;
color: #fff;
text-align: center;
width: 200px;
height: 50px;
line-height: 50px;
text-decoration: none;
border-radius: 2px;
}
a:hover {
background-color: #a5281b;
}
body > a {
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.md-modal {
position: fixed;
top: 50%;
left: 50%;
width: 50%;
max-width: 630px;
min-width: 320px;
height: auto;
z-index: 2000;
visibility: hidden;
transform: translateX(-50%) translateY(-50%);
}
.md-modal:target {
visibility: visible;
}
.md-overlay {
position: fixed;
width: 100%;
height: 100%;
visibility: hidden;
top: 0;
left: 0;
z-index: 1000;
opacity: 0;
background: rgba(143,27,15,0.8);
transition: all 0.3s;
}
.md-modal:target ~ .md-overlay {
opacity: 1;
visibility: visible;
}
/* Content styles */
.md-content {
color: #fff;
background: #e74c3c;
position: relative;
border-radius: 3px;
margin: 0 auto;
}
.md-content h3 {
margin: 0;
padding: 0.4em;
text-align: center;
font-size: 2.4em;
font-weight: 300;
opacity: 0.8;
background: rgba(0,0,0,0.1);
border-radius: 3px 3px 0 0;
}
.md-content > div {
padding: 15px 40px 30px;
margin: 0;
font-weight: 300;
font-size: 1.15em;
}
.md-content > div p {
margin: 0;
padding: 10px 0;
}
.md-content > div ul {
margin: 0;
padding: 0 0 30px 20px;
}
.md-content > div ul li {
padding: 5px 0;
}
.md-content a {
display: block;
margin: 0 auto;
font-size: 0.8em;
}
/* Effect */
.md-modal .md-content {
-webkit-transform: scale(0.7);
-moz-transform: scale(0.7);
-ms-transform: scale(0.7);
transform: scale(0.7);
opacity: 0;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.md-modal:target .md-content {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
MODAL
<div class="md-modal" id="modal">
<div class="md-content">
<h3>Modal Dialog</h3>
<div>
<p>This is a modal window.</p>
<a class="md-close" href="#">Close me!</a>
</div>
</div>
</div>
<div class="md-overlay"></div>
If you don't feel comfortable using visibility: hidden you can use display: none instead. But you better remove the transitions in that case (visibility can be used in a transition, display can't).