Show div on hover : div didn't show on hover - css

I have this code :
#banner {-webkit-border-top-left-radius: 100px; -webkit-border-top-right-radius: 100px; -moz-border-radius-topleft: 100px; -moz-border-radius-topright: 100px; border-top-left-radius: 100px; border-top-right-radius: 100px; position:relative;}
#submenu { color: #fff; margin: 0 2%; position: relative; bottom: -0px; text-align: center; font-family: Oswald; font-weight: 700; font-size: 15px; padding:3px; z-index:1; visibility:hidden; opacity:0; -webkit-transition:300ms; -moz-transition:300ms; -o-transition:300ms; transition:300ms; }
#banner:hover #submenu { visibility:visible; opacity:1; }
And when I hover the #banner ID, the #submenu won't show. Is there something I'm doing wrong?
Thanks for your help.
EDIT : Here's the HTML code, if necessary :
<div id="banner"><div id="submenu">foo</div></div>

Check this: http://jsfiddle.net/4mcz0axk/
Div is showing up but the text of the color is white so it might not be visible.
In the fiddle shared, I intentionally changed it to black and it is working perfectly fine.
#banner {
-webkit-border-top-left-radius: 100px;
-webkit-border-top-right-radius: 100px;
-moz-border-radius-topleft: 100px;
-moz-border-radius-topright: 100px;
border-top-left-radius: 100px;
border-top-right-radius: 100px;
position: relative;
}
#submenu {
color: black;
margin: 0 2%;
position: relative;
bottom: -0px;
text-align: center;
font-family: Oswald;
font-weight: 700;
font-size: 15px;
padding: 3px;
z-index: 1;
visibility: hidden;
opacity: 0;
-webkit-transition: 300ms;
-moz-transition: 300ms;
-o-transition: 300ms;
transition: 300ms;
}
#banner:hover #submenu {
visibility: visible;
opacity: 1;
}

Related

Hover effect not working correctly in google chrome

I watched a video on Youtube about the hover effect, and I'm trying to do it by myself, but the problem is it's not working on google chrome: :before and :after background overflow when the transition executes.
In Firefox it works without any problem.
I thought it might be happening because I didn't use any prefixes, so I includes prefixes in code but the problem didn't go away
to be clear my problem
background of :before and :after show out of button border
body {
display: flex;
margin: 0;
padding: 0;
align-items: center;
justify-content: center;
height: 100vh;
}
a {
overflow: hidden;
display: block;
position: relative;
text-decoration: none;
color: #000;
border: 4px solid #000;
padding: 10px 30px;
font-size: 20px;
letter-spacing: 12px;
border-radius: 30px;
-webkit-border-radius: 30px;
text-transform: uppercase;
transition:color 1s ease-in-out;
transition-delay: 1s;
}
a:before {
content:'';
position: absolute;
top: 50%;
left: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,left,opacity;
transition-delay: 0s,1s,1.5s;
transition-duration: 1s,1s,0s;
}
a:hover:before {
border-radius:100%;
-webkit-border-radius:100%;
opacity:1;
left: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,left,transform;
transitiion-delay:0s,0.5s,2s;
transition-duration: 0s,0.5s,1s;
}
a:after {
content:'';
position: absolute;
top: 50%;
right: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,right,opacity;
transition-delay: 0s,1s,1.5s;
transition-duration: 1.5s,1s,0s;
}
a:hover:after {
opacity:1;
right: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,right,transform;
transitiion-delay:0s,0.5s,2s;
transition-duration: 0s,0.5s,1s;
}
a:hover{
color:#FFF;
}
Button
You have written transitiion instead of transition several times.
Your transition seems to be working (even if you do not say what you would like to do), it's just a little long.
You can play with the delay to change the duration of the animation, here is your code with shortened delays:
body {
display: flex;
margin: 0;
padding: 0;
align-items: center;
justify-content: center;
height: 100vh;
}
a {
overflow: hidden;
display: block;
position: relative;
text-decoration: none;
color: #000;
border: 4px solid #000;
padding: 10px 30px;
font-size: 20px;
letter-spacing: 12px;
border-radius: 30px;
-webkit-border-radius: 30px;
text-transform: uppercase;
transition:color .2s ease-in-out;
transition-delay: .1s;
}
a:before {
content:'';
position: absolute;
top: 50%;
left: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,left,opacity;
transition-delay: 0s,.5s,.5s;
transition-duration: .5s,.5s,0s;
}
a:hover:before {
border-radius:100%;
-webkit-border-radius:100%;
opacity:1;
left: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,left,transform;
transition-delay:0s,0.2s,.2s;
transition-duration: 0s,0.2s,.2s;
}
a:after {
content:'';
position: absolute;
top: 50%;
right: 60px;
height: 8px;
width: 8px;
background-color: #F00;
transform:scale(0.8);
-webkit-transform:scale(0.8);
border-radius:100%;
-webkit-border-radius:100%;
z-index: -1;
opacity:0;
transition-property:transform,right,opacity;
transition-delay: 0s,.2s,.2s;
transition-duration: .2s,.2s,0s;
}
a:hover:after {
opacity:1;
right: 10px;
transform:scale(33);
-webkit-transform:scale(33);
transition-property:opacity,right,transform;
transition-delay:0s,0.2s,.2s;
transition-duration: 0s,0.2s,.2s;
}
a:hover{
color:#FFF;
}
Button
I'm not sure to understand your problem but if it is the absence of transition it could be because you have wrote transitiion-delay instead of transition-delay.
I have tried your code with Chrome and Firefox and didn't noticed a difference.
You can learn more about the need (or absence of need) for prefixes on this website : https://caniuse.com/#search=transform

How can i get this arrow inside my border?

I have a currency converter,
This is how it looks like:
https://gyazo.com/661e6713051bb5ddb288a92f66b24c92
So, I have that arrow inserted after a class with :after , however, on some themes(We are doing a project for shopify) i have to give the arrow a right in order for it to look good. Any ideeas how can i get the arrow inside the border?
the css looks like
.vitals-nice-select {
-webkit-tap-highlight-color: transparent;
background-color: #fff;
color: #333;
box-sizing: border-box;
clear: both;
cursor: pointer;
display: block;
float: left;
font-family: inherit;
font-size: 14px;
font-weight: normal;
height: 42px;
line-height: 40px;
outline: none;
padding-left: 18px;
padding-right: 23px;
position: relative;
text-align: left !important;
webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: auto;
border-radius: 5px;
border: solid 1px #e8e8e8;
}
.vitals-nice-select:hover {
border-color: #dbdbdb;
}
and for the arrow
.vitals-nice-select:after {
border-bottom: 2px solid #999;
border-right: 2px solid #999;
content: \'\';
display: block;
height: 5px;
margin-top: -4px;
pointer-events: none;
position: absolute;
right: 12px;
top: 50%;
-webkit-transform-origin: 66% 66%;
-ms-transform-origin: 66% 66%;
transform-origin: 66% 66%;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transition: all 0.15s ease-in-out;
transition: all 0.15s ease-in-out;
width: 5px;
}
Is this what u want?
.vitals-nice-select {
-webkit-tap-highlight-color: transparent;
background-color: #fff;
color: #333;
box-sizing: border-box;
clear: both;
cursor: pointer;
display: block;
float: left;
font-family: inherit;
font-size: 14px;
font-weight: normal;
height: 42px;
line-height: 42px;
outline: none;
padding-left: 18px;
padding-right: 30px;
position: relative;
text-align: left !important;
webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: auto;
border-radius: 5px;
border: solid 1px #e8e8e8;
}
.vitals-nice-select:hover {
border-color: #dbdbdb;
}
.vitals-nice-select:after {
border-bottom: 2px solid #999;
border-right: 2px solid #999;
content: '';
display: block;
height: 5px;
pointer-events: none;
position: absolute;
right: 12px;
top: 50%;
transform: rotate(45deg) translateX(-50%);
transition: all 0.15s ease-in-out;
width: 5px;
}
<div class="vitals-nice-select">TextTextText</div>
See the fiddle here: https://jsfiddle.net/9o1L1Lg4/
Add the following properties:
.vitals-nice-select {
position: relative;
}
.vitals-nice-select:after {
position: absolute;
right: 0;
/* If you want to center it vertically add the following properties */
top: 50%;
transform: translatey(-50%);
}

Transition not working on hover

I don't know but for some reasons, transition doesn't seem to be working. I am testing this Google Chrome.
[data-title] {
position: relative;
margin: 100px;
}
[data-title]:hover:before {
transform: translate(-50%, 0);
width: 18px;
height: 6px;
left: 50%;
margin-top: 0px;
top: 100%;
opacity: 1;
pointer-events: auto;
-webkit-transition: all 0.25s;
transition: all 0.25s;
content: '';
position: absolute;
z-index: 10;
box-sizing: border-box;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 10px solid #00204e;
}
[data-title]:hover:after {
transform: translate(-50%, 0);
left: calc(50%);
margin-top: 10px;
top: 100%;
opacity: 1;
pointer-events: auto;
-webkit-transition: all 0.25s;
transition: all 0.25s;
font-weight: normal;
text-shadow: none;
background: #00204e;
border-radius: 4px;
color: #fff;
content: attr(data-title);
padding: 10px;
position: absolute;
white-space: normal;
width: max-content;
font-size: 12px;
font-family: 'Helvetica Neue';
line-height: normal;
max-width: 150px;
text-align: left;
height: auto;
display: inline-block;
}
<span class="dijitButtonContents" id="saveButton" data-title="Save as draft"><span id="saveButton_label">Save</span></span>
Can anyone help where I am going wrong or am I missing something?
I have even tried to make transition timing to +1 seconds but still it doesn't reflects the same.
You have not set anything for the original state so the transition doesn't know what to go from. If you are only wanting to transition the item's appearance - eg fade in or out, then you need to do something like transition the opacity:
[data-title] {
position: relative;
margin: 100px;
}
[data-title]:before {
width: 18px;
height: 6px;
left: 50%;
margin-top: 0px;
top: 100%;
opacity: 1;
content: '';
position: absolute;
z-index: 10;
box-sizing: border-box;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 10px solid #00204e;
transform: translate(-50%, 0);
opacity: 0;
transition: opacity 0.5s;
pointer-events: none;
}
[data-title]:after {
transform: translate(-50%, 0);
left: calc(50%);
margin-top: 10px;
top: 100%;
opacity: 1;
font-weight: normal;
text-shadow: none;
background: #00204e;
border-radius: 4px;
color: #fff;
content: attr(data-title);
padding: 10px;
position: absolute;
white-space: normal;
width: max-content;
font-size: 12px;
font-family: 'Helvetica Neue';
line-height: normal;
max-width: 150px;
text-align: left;
height: auto;
display: inline-block;
opacity: 0;
transition: opacity 0.5s;
pointer-events: none;
}
[data-title]:hover:before,
[data-title]:hover:after {
opacity: 1;
pointer-events: auto;
}
<span class="dijitButtonContents" id="saveButton" data-title="Save as draft"><span id="saveButton_label">Save</span></span>
If you want something to transition from one state to another, you have to define both states. This means having a base-style and a :hover-style.
For example:
.test {
width: 100px;
height: 50px;
background: red;
transition: all 2s;
}
.test:hover {
height: 100px;
}
<div class="test">test</div>
This works, because there is an initial state for the height attribute. This however:
.test {
width: 100px;
background: red;
transition: all 2s;
}
.test:hover {
height: 300px;
}
<div class="test">test</div>
This will not work, because the browser doesn't have a specified height as an initial state.

Why are my absolutely positioned elements in different places on depending on browser/devices?

I have about 6 divs that I set to position: absolute.
After reading other threads, I made sure the parent element was set to position: relative,
Still for some reason the vertical positioning of these elements differ depending on browser/device.
For example, the positioning looks okay on chrome for macbook.
But it is off on Safari for Macbook, Safari on iPad as well as Chrome and IE for Windows.
http://codepen.io/donnaloia/pen/WbYbLa
It is the suggestion divs (in light gray), that are not positioning correctly.
What am I doing wrong here? Why is this happening?
.backgroundiv {
background-image: url(/static/img/bg-hero.jpg);
width: 100%;
position: relative;
padding-top: 25px;
height: 986px;
}
.background2div {
background-color: black;
background-repeat: repeat;
height: 800px;
position: relative;
}
.linecontainer {
width: 486px;
display: inline-block;
margin-left: 68px;
}
.formdiv {
padding-top: 50px;
float: center;
background-color: white;
height: 845px;
margin: 0 auto;
border-radius: 3px;
width: 632px;
position: relative;
}
.selltitle {
font-family: futura;
font-size: 28px;
text-align: center;
padding-bottom: 50px;
}
.forminput {
float:right;
margin-bottom: 32px;
}
.forminput input {
padding-top: .5em;
padding-bottom: .5em;
width: 230px;
}
.forminput submit {
padding-top: .5em;
}
.forminput2 {
float:right;
width: 232px;
margin-bottom: 32px;
}
textarea {
padding: .5em;
width: 221px;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.checkmark1{
top: 228px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmarkimg {
width:20px;
}
.checkmark2{
top:285px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmark3{
top:462px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmark4{
top:545px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
.checkmark5{
top:603px;
display:none;
height: 10px;
position: absolute;
width: 20px;
left: 894px;
}
input.parsley-success,
select.parsley-success,
textarea.parsley-success {
color: #468847;
background-color: #DFF0D8;
border: 1px solid #D6E9C6;
}
input.parsley-error,
select.parsley-error,
textarea.parsley-error {
color: #B94A48;
background-color: #F2DEDE;
border: 1px solid #EED3D7;
}
.inputholder.parsley-success.checkmarksuccess {
display: block;
width:26px;
height:24px;
position:absolute;
}
.parsley-errors-list {
margin: 2px 0 3px 0;
padding: 0;
list-style-type: none;
font-size: 0.9em;
line-height: 0.9em;
opacity: 0;
position: absolute;
padding-top: 6px;
font-size:14px;
-moz-opacity: 0;
-webkit-opacity: 0;
transition: all .3s ease-in;
-o-transition: all .3s ease-in;
-ms-transition: all .3s ease-in;
-moz-transition: all .3s ease-in;
-webkit-transition: all .3s ease-in;
}
.parsley-errors-list.filled {
opacity: .5;
}
.suggest1{
opacity: .45;
margin-left:68px;
position:absolute;
top:153px;
font-style: italic;
}
.suggest2{
opacity: .45;
margin-left:68px;
width:150px;
position:absolute;
top:202px;
font-style: italic;
}
.suggest3{
opacity: .45;
margin-left:68px;
position:absolute;
top:297px;
font-style: italic;
}
.suggest4{
opacity: .45;
margin-left:68px;
position:absolute;
top:344px;
font-style: italic;
}
.suggest5{
opacity: .45;
margin-left:68px;
position:absolute;
top:392px;
width:132px;
font-style: italic;
}
.suggest6{
opacity: .45;
margin-left:68px;
position:absolute;
top:440px;
width:132px;
font-style: italic;
}
.suggest7{
color: red;
opacity: .75;
margin-left:325px;
position:absolute;
top:252px;
width:132px;
font-size:14px;
}
.suggest8{
opacity: .45;
margin-left:68px;
position:absolute;
top:489px;
width:132px;
font-style: italic;
}

How do you optimize navigation bar for resizing?

I just started learning html and css about 6 days ago. I do it for a hour a day and I'm having a lot of fun with it. I try to figure most of the issue I have on my own, but I've been having troubles finding resources to fix this problem.
#import url(http://fonts.googleapis.com/css?family=Merriweather);
*
{
text-decoration: none;
box-sizing: border-box;
}
body
{
background-color: #ff9900;
font-family: 'Merriweather', serif;
}
#page
{
margin: -8px;
}
#wrapper
{
/*margin: 1px;*/
}
h2>a
{
margin: -25px;
float: left;
background-color: #ffde00;
color: #097054;
padding: 20px;
}
h2>a:hover
{
color: #ffde00;
transition: .5s ease;
background-color: #6599ff;
}
.container
{
padding: 6px;
padding-right: 50px;
padding-left: 20px;
text-align: center;
background-color: #097054;
}
ul li
{
background-color: #ffde00;
display: inline;
margin: 0 auto;
padding: 10px;
color: #097054;
font-weight: 900;
font-size: 14pt;
}
ul li:hover
{
transition: .5s ease;
background-color: #097054;
border-color: #25C1BC;
color: #ffde00;
}
#p1
{
color: #097054;
height: 25em;
width: 25em;
background-color: #097054;
margin-left: 8px;
margin-top: 20px;
-webkit-transition-timing-function: ease-out;
-webkit-transition-duration: 500ms;
}
p
{
background-color: #ffde00;
padding: 20px;
margin-top: 8px;
-webkit-transition-timing-function: ease-out;
-webkit-transition-duration: 500ms;
}
#p1:hover;
{
/*background-color: #000000;*/
}
p:hover
{
height: -75%;
width: -75%;
padding-bottom: 3.8em;
box-shadow: -5px -5px 0px 0px #097054;
margin-top: 3em;
color: #ffde00;
background-color: #6599ff;
font-weight: 600;
}
Essentially what happens is that my navbar will become extremely disorganized after resizing. This causes links to overlap and look really awful.
Thank you for your time and consideration.
http://jsfiddle.net/JZ9LZ/
Add this .container{white-space: nowrap;}
This question has been asked before Disable line breaks using CSS
There's no way to solve your problem with only html/css as your li elements's width is minimum.
You should decrease the text font-size calculating it on the windows width, but this can be made only with javascript
My advice is to leave this page as before (as I imagine that is only for fun) and when you have good html/css skills you can start studying jQuery <- Very important for the UI

Resources