CSS – Fixing edges after hovering on a rounded image - html

I've created div element, and I also added a border-radius attribute to make the div more aesthetically pleasing. I also added a -webkit-transition: opacity .25s ease attribute to the div to create a transition to a dark overlay when the user hovers over the div. Then, I run into a problem which can be explained by these images.
Cursor outside the div element:
Moving the cursor inside the div element:
The cursor is fully inside the div element:
So, I guess this is a problem with the transition and it's caused by the rounded border of the image. It's kind of annoying and I'd like to remove it but I don't know how to. I've attached the code here:
Note: .memX (where X is a number) refers to each div element. There are like 10 .mem elements.
mem1, .mem2, .mem3, .mem4, .mem5, .mem6, .mem7, .mem8, .mem9, .mem10 {
height: 200px;
width: 200px;
margin: 0px 31px;
display: inline-block;
border-radius: 10px;
border: solid;
border-width: thin;
border-color: #d6d6d6;
overflow: hidden;
}
.overlay {
background: rgba(0,0,0,.4);
text-align: center;
height: 100px;
width: 100%;
padding: 45px 0px 66px 0px;
opacity: 0;
-webkit-transition: opacity .25s ease;
-moz-transition: opacity .25s ease;
}
.insidetext {
font-family: "Source Sans Pro", Helvetica, Arial, sans-serif;
font-weight: lighter;
color: rgba(255,255,255,.85);
font-size: 1.5em;
margin-top: 35px;
}
.mem1:hover .overlay, .mem2:hover .overlay, .mem3:hover .overlay, .mem4:hover .overlay, .mem5:hover .overlay, .mem6:hover .overlay, .mem7:hover .overlay, .mem8:hover .overlay, .mem9:hover .overlay {
border-radius: 10px;
opacity: 1;
}
.mem1 {
background-image: url(members/giles.png);
}
This seems to be a problem in general. You can see this particular problem in action on this CodePen: http://codepen.io/ianfarb/pen/ikeAf

Try using this..
body {
background: #e7e7e7;
}
#box {
width: 300px;
height: 200px;
box-shadow: inset 1px 1px 40px 0 rgba(0, 0, 0, .45);
border-bottom: 2px solid #fff;
border-right: 2px solid #fff;
margin: 5% auto 0 auto;
background: url(http://ianfarb.com/wp-content/uploads/2013/10/nicholas-hodag.jpg);
background-size: cover;
border-radius: 5px;
overflow: hidden;
position: relative;
}
#overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
/*padding: 45px 0 66px 0;*/
display: table;
width: 100%;
height: 100%;
opacity: 0;
border-radius: 5px;
-webkit-transition: opacity .25s ease;
-moz-transition: opacity .25s ease;
}
#box:hover #overlay {
opacity: 1;
}
#plus {
font-family: Helvetica;
font-weight: 900;
color: rgba(255, 255, 255, .85);
font-size: 96px;
display: table-cell;
vertical-align: middle;
}
http://codepen.io/anon/pen/VLBqvE

Hmm I'm confused as to why you've got so many mem classes. Class names can be reused, ID selectors cannot. So why have .mem1 and so on when you could simply have .mem?
Anyway, to fix your problem all you need to do is add border-radius:5px; to #overlay and that should give you your desired effect.

I your example you have two div one is parent (box) and another is chilled(overlay) and you apply border to parent and your hover effect is on chilled so when you hover it will apply transition on chilled. and chilled has no border-radius: 5px; so apply border-radius: 5px; to your chilled id also. so i think its an overflow issue
But you can try this soluttion:
solution is remove delay from transition then it works because of delay it will give you problem.
See this example for removed delay from transition :http://jsfiddle.net/9phk87x8/ i think it will work for you.
#overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
-webkit-transition: opacity ease;
-moz-transition: opacity ease;
}

Related

Limit link width in relative div [duplicate]

This question already has answers here:
How to set width of a inline element? [duplicate]
(4 answers)
How can I make a div not larger than its contents?
(43 answers)
Closed 3 years ago.
The code below shows a tooltip when hovering over links. For some reason, I can't limit the width of the link inside of the div, so the hover effect happens at any point along the width of the parent div, which isn't what I want. I want the hover effect to be limited to the width of the link's text.
.show {
position: relative;
}
.show a {
max-width: 20%;
}
.show .tooltip {
/*visiblity: hidden; */
display: none;
position: absolute;
top: 0;
left:5%;
margin-top: -30px; /* approx adjustment for arrow */
margin-left: 25px; /* approx adjustment for arrow */
}
.show a:hover + .tooltip,
.show a:focus + .tooltip {
cursor: pointer;
display: block;
/*visibility: visible; */
width: 75%;
line-height: 20px;
padding: 8px;
font-size: 14px;
text-align: center;
z-index: 999;
color: rgb(113, 157, 171);
background: rgb(255, 255, 255);
border: 4px solid rgb(255, 255, 255);
border-radius: 5px;
text-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 1px;
box-shadow: #333 -4px 4px 16px 2px;
-webkit-transition: opacity 100ms ease-in;
-o-transition: opacity 100ms ease-in;
-moz-transition: opacity 100ms ease-in;
transition: opacity 100ms ease-in;
pointer-events: none;
}
.show .tooltip:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-width: 10px;
border-style: solid;
border-color: transparent #FFFFFF transparent transparent;
top: 22px;
left: -23px;
}
a {
max-width: 20%;
max-width: 20vw;
}
<div class="lev2">
<div class="show">
<h3>Link</h3>
<div class="tooltip">
<h2>h2</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
</div>
</div>
</div>
Edit: Switching the a or h3 element to inline block changes the dimensions of the div, giving an unwanted margin and/or padding. Setting margin/padding of all elements involved to 0 doesn't resolve this.
Before:
After:

How to format text with hover overlay image

I have the following code with the goal to display a name without hovering centered in the shape, then after hovering having a bio of 5 lines all centered with minimal spacing between line breaks.
The problem in my code currently is formatting the front-side to be all centered and have the same big font as the after-hover, and even more notably wrong- the info on the back is coming off the end of the shape. Not centered.
<html>
<div id="box">
John Doe
<div id="overlay">
<span id="plus">Title:<br>DOB:<br>Hometown:<br>Info4:<br>Info5:</span>
</div>
</div>
<style>
body {
background: -1;
}
#box {
width: 300px;
height: 200px;
box-shadow: inset 1px 1px 40px 0 rgba(0, 0, 0, 0.45);
border-bottom: 2px solid #fff;
border-right: 2px solid #fff;
margin: 5% auto 0 auto;
background-size: cover;
border-radius: 5px;
overflow: hidden;
/* NEW */
line-height: 200px;
text-align: center;
position: relative;
}
#overlay {
background: rgba(0, 0, 0, 0.75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
-webkit-transition: opacity 0.25s ease;
-moz-transition: opacity 0.25s ease;
/* NEW */
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
#box:hover #overlay {
opacity: 1;
}
#plus {
font-family: Helvetica;
font-weight: 900;
color: rgba(255, 255, 255, 0.85);
font-size: 24px;
}
</style>
</html>
This isn't an answer to all of your questions, but to get the font styles to be the same, add the font styling that you have for #plus to the #box selector instead. You will have to change the color for the box selector to black and for #plus you can leave what you currently have for the color.

Css Transition is not working as intended

I could really use some help in my css code.
I'm trying to make my <h1> change color and shape using the transition property.
I want the shape and color to change slowly while I hover over the headline,
but currently only the color is affected, and the shape changes independently.
my code is as follows :
html :
<h1 class="box">Abcdefg</h1>
css :
.box {
background: #2db34a;
margin: 1px auto;
transition: background 1s linear;
border-radius: 0.3%;
color: white;
cursor: pointer;
height: 95px;
line-height: 95px;
text-align: center;
width: 400px;
}
.box:hover {
background: #ff7b29;
border-radius: 50%;
}
thanks.
You just need to add border-radius to your transition
.box {
background: #2db34a;
margin: 1px auto;
transition: background 1s linear, border-radius 1s linear;
border-radius: 0.3%;
color: white;
cursor: pointer;
height: 95px;
line-height: 95px;
text-align: center;
width: 400px;
}
.box:hover {
background: #ff7b29;
border-radius: 50%;
}
<h1 class="box">Abcdefg</h1>
You have the next line of code:
transition: background 1s linear;
The transition only works on the background right now. If you change background to all the transition will work on both background and border-radius, like this:
transition: all 1s linear;
Use all in the transition setting to affect both the border-radius and the background-color:
.box {
background: #2db34a;
margin: 1px auto;
transition: all 1s linear;
border-radius: 0.3%;
color: white;
cursor: pointer;
height: 95px;
line-height: 95px;
text-align: center;
width: 400px;
}
.box:hover {
background: #ff7b29;
border-radius: 50%;
}
<h1 class="box">Abcdefg</h1>
Transitions work only on properties that have numbers. That being said, the question is it should work for the border-radius as well. But the problem here is the browser is unable to find the initial state of the property. Just add border-radius: 0% and it should work.
HTML code:
<p> the code is :</p>
<h1 class="sheet">Abcdefg</h1>
CSS Code:
css code :
.sheet {
background: blue;
margin: 1px auto;
transition: background 5s linear , border-radius 5s ease-in-out ;
color: white;
cursor: pointer;
height: 95px;
line-height: 95px;
text-align: center;
width: 400px;
}
.sheet:hover {
background: red;
color:grey;
border-radius: 40%;
}

Chrome fixed div disappearing when hovering over links

So I'm working on a site (beta.kylehorkley.com). The weirdest thing is happening. I'm working on a sidebar type thing (it appears once the window is small enough). However, when I hover over the links in the side bar, the side bar disappears and then reappears about a second later. This is happening in Chrome and Opera (Firefox and Edge work as expected).
Sidebar HTML:
<div id="sidebar" class="sidebar">
home
contact
portfolio
about
</div>
Sidebar CSS:
.sidebar {
background-color: rgba(255, 255, 255, 0.95);
height: calc(100% - 91px);
overflow-x: hidden;
position: fixed;
top: 91px; left: 0;
width: 100%;
z-index: 999;
}
Sidebar link CSS:
.sidelink {
border-bottom: 3px solid;
border-bottom-color: transparent;
color: rgb(50, 125, 150);
display: block;
font-family: "Varela Round";
font-size: 20px;
font-weight: 400;
margin: 26px 24px 0 24px;
opacity: 0.8;
padding: 0 4px 11px 4px;
text-transform: uppercase;
transition: opacity .35s ease;
}
.sidelink:hover {
opacity: 1;
transition: opacity .35s ease;
}
.sidelink.active {
font-weight: bold;
opacity: 1;
}
Instead of changing the opacity, change the color and this works(tried and tested)..This will fix the disappearing issue..
.sidelink {
border-bottom: 3px solid;
border-bottom-color: transparent;
color:#a9c9d3;
display: block;
font-family: "Varela Round";
font-size: 20px;
font-weight: 400;
margin: 26px 24px 0 24px;
padding: 0 4px 11px 4px;
text-transform: uppercase;
transition: all ease 0.3s;
}
.sidelink:hover {
color: rgb(50, 125, 150);
transition: all ease 0.3s;
}
Replace your class with the above code.. #a9c9d3 is the exact color when you change the opacity to 0.8. And this will fix the div disappearing issue..

CSS transition fade out using opacity is not working

I am trying to have a div where on hover the image fades out (so you can only see the gray background behind) and some text fades in. I have been trying to do this using CSS transitions, however the opacity does not seem to change (i.e. I can still see the background image).
HTML:
<div id='options'>
<div class='option'>
<div class='back-option'>
</div>
<div class='front-option'>
Add post
</div>
</div>
</div>
CSS:
#options {
font-family: 'Segoe UI', 'Arial', sans-serif;
}
.option {
position: relative;
width: 6.25em;
height: 6.25em;
border-radius: 5px;
cursor: pointer;
background-color: #363636;
}
.back-option {
position: absolute;
width: 6.25em;
height: 6.25em;
border-radius: 5px;
background-image: url(http://png-5.findicons.com/files/icons/2672/pixel_ui/16/add.png);
background-size: contain;
-webkit-box-shadow: inset 0px 0px 0px 2px rgba(0,0,0,0.75);
-moz-box-shadow: inset 0px 0px 0px 2px rgba(0,0,0,0.75);
box-shadow: inset 0px 0px 0px 2px rgba(0,0,0,0.75);
opacity: 1;
transition: opacity 0.5s;
}
.back-option:hover {
opacity: 0;
}
.front-option {
position: absolute;
width: 6.25em;
height: 6.25em;
border-radius: 5px;
color: #FFFFFF;
font-weight: bold;
text-align: center;
line-height: 6.25em;
opacity: 0;
transition: opacity 0.5s;
}
.front-option:hover {
opacity: 1;
}
Here is a JSBin of it.
The hover isn't triggering because of the div placed over the top. I've simply modified the css to detect the hover on its parent instead.
.option:hover .back-option {
opacity: 0;
}
Live example: http://jsbin.com/cucadami/4/edit
.back-option doesn't get the event mouseover , cause another element is over it.
do
#options:hover .back-option {
opacity: 0;
}
and it will work.
you could as well give a background-color to .front-option, wich stands on top, and drop hover rules for .back-option