.demo-3 {
margin-top: 25px;
position: relative;
width: 300px;
height: 200px;
overflow: hidden;
float: left;
margin-right: 20px
}
.demo-3 figure {
margin: 0;
padding: 0;
position: relative;
cursor: pointer;
margin-left: -250px
}
.demo-3 figure img {
display: block;
position: relative;
z-index: 10;
margin: -150px 0;
}
.demo-3 figure figcaption {
display: block;
position: absolute;
z-index: 5;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
.demo-3 figure h2 {
font-family: 'Lato';
color: #fff;
font-size: 20px;
text-align: left
}
.demo-3 figure p {
display: block;
font-family: 'Lato';
font-size: 12px;
line-height: 18px;
margin: 0;
color: #fff;
text-align: left;
}
.demo-3 figure figcaption {
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 29px 44px;
background-color: rgba(26, 76, 110, 0.5);
text-align: center;
backface-visibility: hidden;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
transform: rotateY(-180deg);
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s
}
.demo-3 figure img {
backface-visibility: hidden;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s
}
.demo-3 figure:hover img,
figure.hover img {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg)
}
.demo-3 figure:hover figcaption,
figure.hover figcaption {
-webkit-transform: rotateY(0);
-moz-transform: rotateY(0);
transform: rotateY(0)
}
<figure>
<img src="D:\\ps\Notepad++\preview.jpg" alt="" />
<figcaption>
<h2>This is a cool title!</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nost.</p>
</figcaption>
</figure>
</li>
</ul>
I saw this image animation on the internet and thought it was perfect for my idea. The problem was that the image was not positioned correctly in the box so i did some changes in the css code. Now that the image is aligned properly the text which was supposed to be on the back side of the picture got vanished because of the changes i did in the margin property. This is the url of the image if you need to see the original image (http://creativenerds.co.uk/wp-content/uploads/2015/08/wet-ink.jpg). Any help will be highly appreciated. Thanks :)
Related
I have an easy question for CSS guru that is ruining my weekend.
Basically I have a div with an image on the left and some text on the right.
I need that the box height is the same of the content text so for example in the image below the last line is outside the box while I need that the box is height like the content.
I cannot use fixed height due to the text can change inside the box, I need only a min-height already defined.
Some guru can help me?
<a href="#" class="myClass">
<div class="postImageUrl" style="overflow:hidden; z-index: 10; max-width: 100%;">
<div class="imgUrl" style="background-image:url(http://cdn8.openculture.com/wp-content/uploads/2015/03/17231820/Lorem-Ipsum.jpg);">
</div>
</div>
<div class="centered-text-area clearfix">
<div class="centered-text">
<div class="myClass-content">
<div class="ctaText" style="float:left;">
UpNeXt
</div>
<div style="clear:both;"></div>
<div class="postTitle" style="float:left;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat
</div>
</div>
</div>
</div>
</a>
And this is the <style>
.myClass
, .myClass .postImageUrl
, .myClass .imgUrl
, .myClass .centered-text-area {
min-height: 100px;
position: relative;
}
.myClass
, .myClass:hover
, .myClass:visited
, .myClass:active {
border:0!important;
}
.myClass {
display: block;
transition: background-color 250ms;
webkit-transition: background-color 250ms;
width: 100%;
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #eaeaea;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
}
.myClass:active
, .myClass:hover {
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #FFFFFF;
}
.myClass .postImageUrl
, .myClass .imgUrl {
background-position: center;
background-size: cover;
float: left;
margin: 0;
padding: 0;
}
.myClass .postImageUrl {
width: 30%;
}
.myClass .imgUrl {
width: 100%;
}
.myClass .centered-text-area {
float: right;
width: 70%;
}
.myClass .centered-text {
display: table;
min-height: 100px;
left: 0;
position: absolute;
top: 0;
}
.myClass .myClass-content {
display: table-cell;
margin: 0;
padding: 0 74px 0 18px;
position: relative;
vertical-align: middle;
width: 100%;
}
.myClass .ctaText {
border-bottom: 0 solid #fff;
color: #34495E;
font-size: 13px;
font-weight: bold;
letter-spacing: .125em;
margin: 0;
padding: 0;
text-decoration: underline;
}
.myClass .postTitle {
color: #000000;
font-size: 18px;
font-weight: 600;
margin: 0;
padding: 0;
}
.myClass .ctaButton {
background-color: #FFFFFF;
margin-left: 10px;
position: absolute;
right: 0;
top: 0;
}
.myClass:hover .imgUrl {
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-o-transform: scale(1.2);
-ms-transform: scale(1.2);
transform: scale(1.2);
}
.myClass .imgUrl {
-webkit-transition: -webkit-transform 0.4s ease-in-out;
-moz-transition: -moz-transform 0.4s ease-in-out;
-o-transition: -o-transform 0.4s ease-in-out;
-ms-transition: -ms-transform 0.4s ease-in-out;
transition: transform 0.4s ease-in-out;
}
You can find the problem here http://jsfiddle.net/L26s1vc5/
This is what I see now
While this is what I expect to have:
The min-height is 100px.
I already tested with height:100%, overflow-y:auto, height:auto without success :(
Thanks for your help, Alex.
You have two issues causing your problem. You have a clearing issue and an absolute positioning issue. Inside of .myClass you have two floated divs. That alone would cause the issue you are having. You've even attempted to fix it in two places. You added a class of clearfix in one place (which would only work if you had a css rule to match). You also have an empty div with an inline styling of clear: both;, though for that to work you would need to have it as the third div in your link.
Still, even if either of the above were working properly the issue wouldn't have been fixed. This is because of your absolute positioning on .centered-text. When you absolutely position something you take it out of the flow of your document. This means that it's parent has no idea the size of what's inside of it. All of your sizing was coming from your liberal use of min-height: 100px. If you remove the absolute positioning on .centered-text and use the clearfix properly then your code works just fine.
.myClass,
.myClass .postImageUrl,
.myClass .imgUrl,
.myClass .centered-text-area {
min-height: 100px;
position: relative;
}
.myClass,
.myClass:hover,
.myClass:visited,
.myClass:active {
border: 0!important;
}
.myClass {
display: block;
transition: background-color 250ms;
webkit-transition: background-color 250ms;
width: 100%;
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #eaeaea;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17);
}
.myClass:active,
.myClass:hover {
opacity: 1;
transition: opacity 250ms;
webkit-transition: opacity 250ms;
background-color: #FFFFFF;
}
.myClass .postImageUrl,
.myClass .imgUrl {
background-position: center;
background-size: cover;
float: left;
margin: 0;
padding: 0;
}
.myClass .postImageUrl {
width: 30%;
}
.myClass .imgUrl {
width: 100%;
}
.myClass .centered-text-area {
float: right;
width: 70%;
}
.myClass .centered-text {
display: table;
min-height: 100px;
/* Removed absolute positioning*/
}
.myClass .myClass-content {
display: table-cell;
margin: 0;
padding: 0 74px 0 18px;
position: relative;
vertical-align: middle;
width: 100%;
}
.myClass .ctaText {
border-bottom: 0 solid #fff;
color: #34495E;
font-size: 13px;
font-weight: bold;
letter-spacing: .125em;
margin: 0;
padding: 0;
text-decoration: underline;
}
.myClass .postTitle {
color: #000000;
font-size: 18px;
font-weight: 600;
margin: 0;
padding: 0;
}
.myClass .ctaButton {
background-color: #FFFFFF;
margin-left: 10px;
position: absolute;
right: 0;
top: 0;
}
.myClass:hover .imgUrl {
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-o-transform: scale(1.2);
-ms-transform: scale(1.2);
transform: scale(1.2);
}
.myClass .imgUrl {
-webkit-transition: -webkit-transform 0.4s ease-in-out;
-moz-transition: -moz-transform 0.4s ease-in-out;
-o-transition: -o-transform 0.4s ease-in-out;
-ms-transition: -ms-transform 0.4s ease-in-out;
transition: transform 0.4s ease-in-out;
}
/* Added clearfix class here so that it can work properly*/
.clearfix:after {
content: "";
display: block;
clear: both;
}
<a href="#" class="myClass clearfix"><<!-- moved clearfix here so it can take effect for the necessary area -->>
<div class="postImageUrl" style="overflow:hidden; z-index: 10; max-width: 100%;">
<div class="imgUrl" style="background-image:url(http://cdn8.openculture.com/wp-content/uploads/2015/03/17231820/Lorem-Ipsum.jpg);">
</div>
</div>
<div class="centered-text-area">
<div class="centered-text">
<div class="myClass-content">
<div class="ctaText" style="float:left;">
UpNeXt
</div>
<div class="postTitle" style="float:left;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet
dolore magna aliquam erat volutpat
</div>
</div>
</div>
</div>
</a>
All I did remove said absolute positioning (it wasn't doing anything that I could tell), moved your clearfix to the proper place, removed your extra div (also a clearfix attempt) and added a clearfix class to the end of your css.
It looks like you've tried to do a lot of things to make this code work. You may want to go through and see what's doing what, a lot of it looks like it's not doing anything at all.
https://jsfiddle.net/dixalex/ojoevj1k/
The fiddle has the solution done via jQuery using the .height() call and JavaScript using the setInterval call. Every 50 milliseconds, the function will check to see if the image height is the same height as the container with the text. If they are not equal in pixel height, CSS is applied directly to make them equal.
Since this is dynamic, I did not have to change any of your CSS.
var makeSameHeight = setInterval( function() {
var currentTextHeight = $('div.myClass-content').height() + "px";
var imgDivHeight = $('div.imgUrl').height() + "px";
if (currentTextHeight === imgDivHeight)
{
var doNothing = "";
} else {
$('div.imgUrl, div.postImageUrl, a.myClass').css("height", currentTextHeight);
}
}, 50);
Only add overflow:hidden;
.myClass .myClass-content {
display: table-cell;
margin: 0;
padding: 0 74px 0 18px;
position: relative;
vertical-align: middle;
width: 100%;
overflow:hidden;
}
If isn't set height:XXpx; the container will fit to the content.
I am experiencing a weird issue where the hover state is still being hovered after the mouse leaves the div. To see this hover over the picture. I tried inspecting but I can't figure it out.
Youtube video https://youtu.be/PX8psGOTbNM
Not working on Wordpress: http://sogomarketingagency.com/test-3/
Works fine on CodePen: http://codepen.io/CookieFresh89/pen/emLXEK
I have tried deactivating all plugins and reverting back to original theme and am still getting this problem.
The Code:
.modal {
display: block;
text-align: center;
width: 185px;
margin: 0 auto;
}
.modal-about > label {
background: #07B288;
border-radius: .3em;
color: #ffffff;
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-left: 0px;
padding: 0.50em 1.0em;
-webkit-transition: all 0.55s;
transition: all 0.55s;
}
.modal-about input {
position: absolute;
left: -50px;
top: 130px;
z-index: -10;
}
#media (min-width: 43.75em) {
.modal-about input {
right: 50px;
}
}
.modal__overlay {
background: rgba(255, 255, 255, 0.9);
bottom: 0;
left: 0;
position: fixed;
right: 0;
text-align: center;
top: 0;
z-index: -800;
}
.modal__box {
padding: 1em .75em;
position: relative;
margin: 1em auto;
max-width: 500px;
width: 90%;
}
#media (min-height: 37.5em) {
.modal__box {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -80%);
-ms-transform: translate(-50%, -80%);
transform: translate(-50%, -80%);
}
}
#media (min-width: 50em) {
.modal__box {
padding: 1.75em;
}
}
.modal__box label {
background: #07B288;
border-radius: 50%;
color: white;
cursor: pointer;
display: inline-block;
height: 1.5em;
line-height: 1.5em;
position: absolute;
font-size: 30px;
right: .5em;
top: .5em;
width: 1.5em;
}
.modal__box h1 {
font-size: 50px;
margin-bottom:0px;
}
.modal__box h2 {
color: #07B288;
margin-bottom: 15px;
margin-top: 10px;
text-transform: uppercase;
}
.modal__box hr {
border: 0;
height: 1px;
background: #E8E8E8;
}
.modal__box p {
text-align: left;
}
.modal__overlay {
opacity: 0;
overflow: hidden;
-webkit-transform: scale(0.5);
-ms-transform: scale(0.5);
transform: scale(0.5);
-webkit-transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
input:checked ~ .modal__overlay {
opacity: 1;
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
-webkit-transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 800;
}
input:focus + label {
-webkit-transform: scale(0.97);
-ms-transform: scale(0.97);
transform: scale(0.97);
}
.about-name-h1 {
margin-top: 10px;
}
.about-wrapper {
width: 185px;
height: 227px;
position: relative;
}
.about-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 40px 0px;
background: rgba(255, 255, 255, 0.75);
visibility: hidden;
opacity: 0;
text-align: center;
text-transform:uppercase;
}
.about-overlay:hover {
padding: 70px 0px;
}
.about-wrapper:hover .about-overlay {
visibility: visible;
opacity: 1;
}
.about-name, .about-overlay {
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.about-name {
padding: 15px 0px;
text-align: center;
border: 1px solid #e8e8e8;
border-top: 0;
font-size: 16px;
background: #ffffff;
margin:0px;
width: 183px;
cursor:pointer;
}
.about-name:hover {
background: #07B288;
color: #fff;
}
.avatar-frame {
border: 2px solid #07B288;
}
.avatar-frame, .avatar-frame img {
width: 120px;
height: 120px;
-webkit-border-radius: 60px;
margin: 0 auto;
/* Saf3+, Chrome */
border-radius: 60px;
/* Opera 10.5, IE 9 */
/*-moz-border-radius: 30px; Disabled for FF1+ */
}
<div class="about-wrapper">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-president.jpg" alt="polaroid" />
<div class="about-overlay">
<h3>Founder</h3>
<div class="modal-about">
<input id="modal-about" type="checkbox" name="modal-about" tabindex="1">
<label for="modal-about">View Profile</label>
<div class="modal__overlay">
<div class="modal__box">
<label for="modal-about">✖</label>
<div class="avatar-frame">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-me-president-circle.jpg" alt="">
</div>
<h1 class="about-name-h1">Garry Howell</h1>
<h2>Founder</h2>
<hr>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra. Suspendisse in volutpat lacus. In enim est, dapibus eget ipsum sed, suscipit ultrices diam.</p>
</div>
</div>
</div>
</div>
</div>
<h4 class="about-name">Garry Howel</h4>
It seems that div.modal__overlay expands div.about-wrapper which creates a wider area to trigger :hover.
Edit: As mentioned by CBroe, descendants trigger the hover states of their ancestors. Since div.modal__overlay is position:fixed, it effectively creates a second hover area for but outside of div.about-wrapper.
I had success by adding visibility to the toggle for div.modal__overlay:
.modal__overlay {
opacity:0;
visibility:hidden;
...
}
input:checked ~ .modal__overlay {
opacity: 1;
visibility:visible;
...
}
However, I'm not sure why this helps, because elements hidden by visibility:hidden are still supposed to affect layout (i.e. take up space). So, if it creates a bigger :hover area with opacity:0, shouldn't it do the same with visibility:hidden? Maybe someone can help clarify this behavior.
Edit: More insight from Cbroe in the comments, below.
I built a demonstration of the difference, below. Try hovering over the blue area for box #1. Then try hovering over the same area on box #2, which is visibility:hidden.
div.container {
position:relative;
width: 200px;
height: 50px;
border: 1px solid #CCC;
margin: 0 0 1em 0;
}
div.prop {
margin-left: 200px;
width: 200px;
height: 50px;
background-color: #0CC;
}
div.prop.invisible {
visibility: hidden;
}
div.container:hover {
background-color: #F00;
}
div.container p {
position:absolute;
top:0;
left:0;
}
<div class="container">
<p>BOX #1</p>
<div class="prop"></div>
</div>
<div class="container">
<p>BOX #2</p>
<div class="prop invisible"></div>
</div>
And here is my working version of your code:
.modal {
display: block;
text-align: center;
width: 185px;
margin: 0 auto;
}
.modal-about > label {
background: #07B288;
border-radius: .3em;
color: #ffffff;
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-left: 0px;
padding: 0.50em 1.0em;
-webkit-transition: all 0.55s;
transition: all 0.55s;
}
.modal-about input {
position: absolute;
left: -50px;
top: 130px;
z-index: -10;
}
#media (min-width: 43.75em) {
.modal-about input {
right: 50px;
}
}
.modal__overlay {
background: rgba(255, 255, 255, 0.9);
bottom: 0;
left: 0;
position: fixed;
right: 0;
text-align: center;
top: 0;
z-index: -800;
}
.modal__box {
padding: 1em .75em;
position: relative;
margin: 1em auto;
max-width: 500px;
width: 90%;
}
#media (min-height: 37.5em) {
.modal__box {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -80%);
-ms-transform: translate(-50%, -80%);
transform: translate(-50%, -80%);
}
}
#media (min-width: 50em) {
.modal__box {
padding: 1.75em;
}
}
.modal__box label {
background: #07B288;
border-radius: 50%;
color: white;
cursor: pointer;
display: inline-block;
height: 1.5em;
line-height: 1.5em;
position: absolute;
font-size: 30px;
right: .5em;
top: .5em;
width: 1.5em;
}
.modal__box h1 {
font-size: 50px;
margin-bottom:0px;
}
.modal__box h2 {
color: #07B288;
margin-bottom: 15px;
margin-top: 10px;
text-transform: uppercase;
}
.modal__box hr {
border: 0;
height: 1px;
background: #E8E8E8;
}
.modal__box p {
text-align: left;
}
.modal__overlay {
opacity:0;
visibility:hidden;
overflow: hidden;
-webkit-transform: scale(0.5);
-ms-transform: scale(0.5);
transform: scale(0.5);
-webkit-transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
input:checked ~ .modal__overlay {
opacity: 1;
visibility:visible;
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
-webkit-transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 800;
}
input:focus + label {
-webkit-transform: scale(0.97);
-ms-transform: scale(0.97);
transform: scale(0.97);
}
.about-name-h1 {
margin-top: 10px;
}
.about-wrapper {
width: 185px;
height: 227px;
position: relative;
}
.about-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 40px 0px;
background: rgba(255, 255, 255, 0.75);
visibility: hidden;
opacity: 0;
text-align: center;
text-transform:uppercase;
}
.about-overlay:hover {
padding: 70px 0px;
}
.about-wrapper:hover .about-overlay {
visibility: visible;
opacity: 1;
}
.about-name, .about-overlay {
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.about-name {
padding: 15px 0px;
text-align: center;
border: 1px solid #e8e8e8;
border-top: 0;
font-size: 16px;
background: #ffffff;
margin:0px;
width: 183px;
cursor:pointer;
}
.about-name:hover {
background: #07B288;
color: #fff;
}
.avatar-frame {
border: 2px solid #07B288;
}
.avatar-frame, .avatar-frame img {
width: 120px;
height: 120px;
-webkit-border-radius: 60px;
margin: 0 auto;
/* Saf3+, Chrome */
border-radius: 60px;
/* Opera 10.5, IE 9 */
/*-moz-border-radius: 30px; Disabled for FF1+ */
}
<div class="about-wrapper">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-president.jpg" alt="polaroid" />
<div class="about-overlay">
<h3>Founder</h3>
<div class="modal-about">
<input id="modal-about" type="checkbox" name="modal-about" tabindex="1">
<label for="modal-about">View Profile</label>
<div class="modal__overlay">
<div class="modal__box">
<label for="modal-about">✖</label>
<div class="avatar-frame">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-me-president-circle.jpg" alt="">
</div>
<h1 class="about-name-h1">Garry Howell</h1>
<h2>Founder</h2>
<hr>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra. Suspendisse in volutpat lacus. In enim est, dapibus eget ipsum sed, suscipit ultrices diam.</p>
</div>
</div>
</div>
</div>
</div>
<h4 class="about-name">Garry Howel</h4>
I have a circle with a hover effect on it and some text under. Now what I'm trying to achieve is to trigger that hover effect when you rollover the entire circle container and not only the circle itself.
DEMO
http://jsfiddle.net/kL0vxrxL/
.icon-circle-box {
text-align: center;
margin: 0 auto 130px;
}
.icon-circle {
display: inline-block;
font-size: 42px;
cursor: pointer;
margin: 0 0 28px;
width: 100px;
height: 100px;
line-height: 100px;
border-radius: 50%;
text-align: center;
position: relative;
z-index: 1;
color: #fff;
}
.icon-circle-box p {
margin-top: 13px;
}
.icon-circle:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content: '';
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.icon-circle:before {
font-family: 'lineicons';
speak: none;
font-size: 42px;
line-height: 100px;
display: block;
}
.circle-effect .icon-circle {
color: #000;
box-shadow: 0 0 0 2px #000;
-webkit-transition: color 0.3s;
-moz-transition: color 0.3s;
transition: color 0.3s;
}
.circle-effect .icon-circle:after {
top: -2px;
left: -2px;
padding: 2px;
z-index: -1;
background: #000;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: -webkit-transform 0.2s, opacity 0.2s;
-moz-transition: -moz-transform 0.2s, opacity 0.2s;
transition: transform 0.2s, opacity 0.2s;
}
.icon-circle:hover {
color: #fff;
}
.icon-circle:hover:after {
-webkit-transform: scale(0.85);
-moz-transform: scale(0.85);
-ms-transform: scale(0.85);
transform: scale(0.85);
opacity: 1;
filter: alpha(opacity=100);
}
<div class="icon-circle-box circle-effect">
<p>Donec id elit non mi porta gravida at eget metus.</p>
</div>
I'm trying to achieve is to trigger that hover effect when you rollover the entire circle container and not only the circle itself.
Then you would add the :hover pseudo-class to the parent element, .icon-circle-box.
Updated Example
.icon-circle-box:hover .icon-circle:after {
-webkit-transform: scale(0.85);
-moz-transform: scale(0.85);
-ms-transform: scale(0.85);
transform: scale(0.85);
opacity: 1;
filter: alpha(opacity=100);
}
I've been trying to add a dropdown menu to the header nav in a website, but the dropdown will simply not be visible outside the header element.
Here's a jsFiddle showing the problem. I've tried setting overflow to visible, but that hasn't worked so far. I'd really appreciate if someone could point me in the right direction
Code:
header {
background-color: white;
width: 100%;
overflow: visible;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
transition: all 0.5s ease;
}
header:after {
content: "";
display: table;
clear: both;
}
header .oc {
height: 105px;
position: relative;
display: inline-block;
width: 100%;
}
.oc {
max-width: 1300px;
margin-left: auto;
margin-right: auto;
padding: 0 10px;
}
.oc:after {
content: "";
display: table;
clear: both;
}
header .nav-logo {
display: block;
left: 10px;
height: 54px;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
}
header .nav-logo {
display: block;
left: 10px;
height: 54px;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
}
header .main-nav {
right: 10px;
position: absolute;
top: 40%;
-webkit-transform: translateY(-40%);
-moz-transform: translateY(-40%);
-ms-transform: translateY(-40%);
-o-transform: translateY(-40%);
transform: translateY(-40%);
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-perspective: 1000;
-webkit-transform: scale3d(1, 1, 1);
}
header .main-nav ul {
margin: 0;
padding: 0;
list-style: none;
position: relative;
display: inline-table;
}
header .main-nav ul li {
display: inline-block;
}
header .main-nav-item {
color: #666668;
font-weight: 200;
font-size: 21px;
margin-left: 25px;
padding: 0 0 4px 0;
position: relative;
outline: none;
transition: all 0.3s ease 0s;
}
header .main-nav-item:after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 2px;
background: #89a959;
content: "";
opacity: 0;
-webkit-transition: opacity 0.3s, -webkit-transform 0.3s;
-moz-transition: opacity 0.3s, -moz-transform 0.3s;
transition: opacity 0.3s, transform 0.3s;
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
transform: translateY(10px);
}
header .main-nav ul ul {
display: none;
background: #fff;
border-top: 2px solid #73973f;
padding: 0;
position: absolute;
top: 150%;
z-index: 10000;
transition: all 0.3s ease 0s;
}
header .main-nav ul ul li {
display: block;
position: relative;
padding: 15px;
transition: all 0.3s ease 0s;
}
header .main-nav ul ul li a {
color: #666;
}
header .main-nav ul ul li:hover {
background: #eee;
}
header .main-nav ul li:hover > ul {
display: block;
}
.pitch {
background-color: #f6faf0;
padding: 40px 0;
position: relative;
text-align: center;
-webkit-transition: height 1.5s ease-in-out, padding 0.5s ease-in-out;
-moz-transition: height 1.5s ease-in-out, padding 0.5s ease-in-out;
transition: height 1.5s ease-in-out, padding 0.5s ease-in-out;
}
.pitch:after {
content: "";
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
bottom: -25px;
z-index: 2;
height: 0;
width: 0;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-top: 25px solid #f6faee;
}
<header>
<div class="oc">
<a href="/" class="nav-logo">
<img src="http://placehold.it/300x50"
</a>
<nav class="main-nav">
<ul>
<li>About</li>
<li>Plans</li>
<li>
Contact
<ul>
<li>Request a Demo</li>
<li>Talk To Us</li>
</ul>
</li>
<li>Request a Demo</li>
<li>API</li>
<li>Login</li>
</ul>
</nav>
</div>
</header>
<div class="pitch">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nec condimentum elit. Cras eget fringilla velit, id pulvinar libero. Sed venenatis, orci eu aliquet lacinia, orci eros pharetra erat, ac bibendum ex purus rhoncus erat. Sed pharetra in orci sed sollicitudin. Aliquam fringilla mollis arcu, aliquam euismod urna commodo nec. Nunc ut lorem augue. Phasellus quis nibh pretium, ultricies mauris et, tincidunt nisi. Suspendisse fermentum, libero eu pulvinar semper, massa ante tincidunt nisi, sed aliquet elit justo a purus.</p>
</div>
It is just a z-index issue. Your header dropdown menu is being "hidden" behind the .pitch content. So I updated your JSFiddle.
Just add position:relative;z-index:2; to .header and position: relative;z-index:1; to .pitch. Then your dropdown will overlay .pitch.
Trying to create similar effect like this: http://callmenick.com/tutorial-demos/image-caption-reveal-on-hover/index-2.html
However i am stuck with my codes and it won't just flip perfectly.
here's my CSS:
/* Paragraphs and Heading 2 styling, change according to your needs */
.slide p, .slide h2 {
color:#ffffff;
padding:10px;
left: -20px;
top: 20px;
position: relative;
}
.slide p {
font-family:'Lato';
font-size:12px;
line-height:18px;
margin: 0;
}
.slide h2 {
font-size:20px;
line-height:24px;
margin: 0;
font-family:'Lato';
}
/* 1. Sliding Up */
.moveup img {
position: absolute;
left: 0;
top: -15px;
width: 100%;
/*Fit the image to its container. the aspect ratio is preserved; the image will not be distorted*/
cursor: pointer;
-webkit-transition: transform 2s ease-in-out;
-moz-transition: top .5s ease-in-out;
-o-transition: top 2s ease-in-out;
transition: transform .5s ease-in-out;
}
.slide:hover img{
-webkit-transform:rotateY(90deg);
backface-visibility:hidden;
/*set to a value to hide the whole image*/
padding-bottom:200px;
}
.slide:hover .a{
-webkit-transform:rotateY(360deg);
/*set to a value to hide the whole image*/
padding-bottom:200px;
}
.a{
transition:.5s ease-in;
}
Any idea which part I made wrong?
Here's the JSFIDDLE: http://jsfiddle.net/r26bz3xn/2/
Thanks for the help in advance!
If you're going to use that example, why not just use their structure? I will say that tutorial seemed to have left out quite a lot of styles that made this thing work. I wish I could explain better as to what you were doing wrong but I've added a working fiddle to the bottom and the code below:
HTML
<figure>
<img src="http://beautyblenderdupe.com/wp-content/uploads/2015/01/01.jpg" alt=""/>
<figcaption>
<h2>This is a cool title!</h2>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nost.</span>
</figcaption>
</figure>
CSS
.slide figure {
margin: 0;
position: relative;
}
.slide figure img {
display: block;
position: relative;
z-index: 10;
max-width: 100%;
height: auto;
}
.slide figure figcaption {
display: block;
position: absolute;
z-index: 5;
padding: 20px;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.slide figure h2 {
font-family:'Lato';
color: #fff;
font-size: 22px;
line-height: 1.2;
font-weight: 700;
margin-bottom: 10px;
}
.slide figure span {
display: block;
font-family:'Lato';
font-size:12px;
line-height:18px;
margin: 0;
color: #FFF;
}
.slide figure figcaption {
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(26, 76, 110, 0.5);
text-align: center;
backface-visibility: hidden;
transform: rotateY(-180deg);
transition: all 0.5s;
}
.slide figure figcaption h3 {
margin-top: 150px
}
.slide figure img {
backface-visibility: hidden;
transition: all 0.5s;
}
.slide figure:hover img,
#effect-2 figure.hover img {
transform: rotateY(180deg);
}
.slide figure:hover figcaption,
#effect-2 figure.hover figcaption {
transform: rotateY(0);
}`enter code here`
FIDDLE