as you can see here http://jsfiddle.net/Ec8kN/ , my css circles are not working properly. Initially I only had one class .circle that I used several times to have multiple circles and it was working fine. I then decided to name each circle differently (i.e. circle-1, circle-2, circle-3) to get a better control with JS at a later stage.
That's where the issues started. Now that I renamed them circle-1, circle-2, etc they won't display correctly anymore. What could be the issue? Many thanks
<div class="circle-1 circlebackground circle_5px_marging">
<p>Créativité</p>
<div class="innercircle">
<p>Le fdfd stimule la dfdsfd du fdfds en le dfdfd à réinventer sa dfdsf de la dfds dfs et donc les fdsfs qu’il peut y fdssf.</p>
</div>
</div>
<div class="circle-2 circlebackground circle_5px_marging">
<p>Circle 2</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
<div class="circle-3 circlebackground">
<p>Circle 3</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
.circle_5px_marging {
margin-right: 30px;
}
.circle-1, .circle-2, .circle-3 {
position: relative;
float: left;
margin-bottom: 10px;
width: 220px;
height: 220px;
border-radius: 50%;
box-shadow: inset 0 0 0 0px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.1);
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
.circlebackground {
border:1px solid #2970AE;
background: #FFF;
}
.innercircle {
position: absolute;
width: inherit;
height: inherit;
border-radius: 50%;
background: #2970AE;
opacity: 0;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-ms-transform: scale(0);
-o-transform: scale(0);
transform: scale(0);
-webkit-backface-visibility: hidden;
}
.circle-1, .circle-2, .circle-3 p {
position: absolute;
top: 50%;
left: 50%;
margin: 0;
color: #2970AE;
letter-spacing: 1px;
font-weight: 700;
font-size: 14px;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.innercircle p {
position: absolute;
top: 50%;
left: 50%;
margin: 0;
color:#fff;
text-align: center;
font-weight: 300;
font-size: 10px;
opacity: 1;
-webkit-transition: all 1s ease-in-out 0.4s;
-moz-transition: all 1s ease-in-out 0.4s;
-ms-transition: all 1s ease-in-out 0.4s;
-o-transition: all 1s ease-in-out 0.4s;
transition: all 1s ease-in-out 0.4s;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.circle-1:hover {
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 1px 2px rgba(0, 0, 0, 0.1);
}
.circle-1:hover .innercircle {
opacity: 1;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
}
.circle-1:hover .innercircle p {
opacity: 1;
}
.clear {
clear: both;
}
Change .circle-1, .circle-2, .circle-3 p to .circle-1 p, .circle-2 p, .circle-3 p. It should work.
As it is now, the properties set under this rule will apply to elements with class as circle-1, circle-2 and the p tag under all elements with class as circle-3.
Fiddle Demo
You need to fix one selector:
.circle-1 p, .circle-2 p, .circle-3 p
Instead of:
.circle-1, .circle-2, .circle-3 p
Like I've written on the previous question of yours, the current selector is applied on .circle-1, .circle-2, and all paragraphs inside .circle-3. If you want it to be applied on every paragraph inside those classes you have to address p on each class separately.
jsFiddle Demo
I can only advise you to restore the common circle class, then add a different id to each circle (e.g. id="circle1") and use the # CSS operator (e.g. #circle1) to customize each circle. That way you can tidy up your CSS code a little bit. For example, your first circle:
<div id="circle-1" class="circle circlebackground circle_5px_marging">
<p>Créativité</p>
<div class="innercircle">
<p>Le fdfd stimule la dfdsfd du fdfds en le dfdfd à réinventer sa dfdsf de la dfds dfs et donc les fdsfs qu’il peut y fdssf.</p>
</div>
Look here.
Going back to one css class for your circles is the way to go. If you need to distinguish them in Javascript then add an id to each circle.
From W3 Schools: The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements.
Furthermore accessing Ids in Javascript is easier and faster than accessing classes. Even though frameworks make it easy and browser are pretty fast nowadays.
I have found the problem.
There is no syntax error but the Circle 1 you have gets overlapped by Circle-2 which you can see by hiding circle 2.
So you just need to change the position of the circle 2.
Related
I need to display a text on the image using CSS. I'm doing that using H2 tag:
<h2 class="post-message">Test</h2>
Here is the code for CSS:
.post-message {
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(0, 0, 0, 0.75);
padding: 4px 8px;
color: white;
margin: 0;
font: 14px Sans-Serif;
}
But the overlay effect is messing things up and here is the code:
.overlay{
overflow: hidden;
background: #000;
}
.overlay img{
-webkit-transition: -webkit-transform .3s ease-out;
-moz-transition: -moz-transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
transition: transform .3s ease-out;
}
.overlay:hover img{
-webkit-transform: scale(1.2) rotate(-5deg);
-moz-transform: scale(1.2) rotate(-5deg);
-o-transform: scale(1.2) rotate(-5deg);
-ms-transform: scale(1.2) rotate(-5deg);
transform: scale(1.2) rotate(-5deg);
opacity: 0.7;
}
I don't know how to explain what happens and I uploaded 2 screens:
This screen shows the original image without Mouse hover: https://s22.postimg.org/xrsohlcw1/without_mouse_over.jpg
On the first image you see a gray background that I don't know from where comes
The second image is the mouse over effect: that gray image is rotating according to overlay effect and is displayed at the right corner only :/
https://s22.postimg.org/a13x0ndmp/gra_color_disappears.jpg
A little red arrow will show you what happens on the second image. A help would be great! I tried all possible things that I knew, expert opinion always is the best solution. Thanks in advance!
<div class="post-thumbnail overlay">
<a href="http://example.com/comey-wikileaks/">
<img src="http://example.com/wp-content/uploads/2017/04/comey-825x510.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" width="825" height="510">
</a>
<h2 class="post-message">Test</h2>
</div>
An img has a "replaced content" layout model and basically treated as an inline element, and that includes space at the bottom by default for the bottom part of characters, so there will be a small space between the bottom of an img and the bottom of the img's container. To remove that gap at the bottom, either make the img display: block or use vertical-align: top.
If the image is rotating so far that you see the corner of it in the bottom/right corner, either increase your scale() or don't rotate as much until you can't see that anymore. I don't see it with the code you provided.
.post-message {
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(0, 0, 0, 0.75);
padding: 4px 8px;
color: white;
margin: 0;
font: 14px Sans-Serif;
}
.overlay {
overflow: hidden;
background: #000;
}
.overlay img {
-webkit-transition: -webkit-transform .3s ease-out;
-moz-transition: -moz-transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
transition: transform .3s ease-out;
}
.overlay:hover img {
-webkit-transform: scale(1.2) rotate(-5deg);
-moz-transform: scale(1.2) rotate(-5deg);
-o-transform: scale(1.2) rotate(-5deg);
-ms-transform: scale(1.2) rotate(-5deg);
transform: scale(1.2) rotate(-5deg);
opacity: 0.7;
}
img {
vertical-align: top;
}
<div class="post-thumbnail overlay">
<a href="http://example.com/comey-wikileaks/">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" width="825" height="510">
</a>
<h2 class="post-message">Test</h2>
</div>
You could actually put your img together with your <h2> inside a <div> and let the whole <div> rotate....
Here is an example base on what you wrote:
(obvously, there's a few things to readjust, but it's more or less what you want, I guess ^^)
.post-message {
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(0, 0, 0, 0.75);
padding: 4px 8px;
color: white;
margin: 0;
font: 14px Sans-Serif;
}
.overlay{
overflow: hidden;
background: #000;
/*these two lines are new*/
display:inline-block;
position:relative;
}
/*I apply style directly on the "overlay"*/
.overlay /*img*/{
-webkit-transition: -webkit-transform .3s ease-out;
-moz-transition: -moz-transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
transition: transform .3s ease-out;
}
.overlay:hover /*img*/{
-webkit-transform: scale(1.2) rotate(-5deg);
-moz-transform: scale(1.2) rotate(-5deg);
-o-transform: scale(1.2) rotate(-5deg);
-ms-transform: scale(1.2) rotate(-5deg);
transform: scale(1.2) rotate(-5deg);
opacity: 0.7;
}
<span class="overlay">
<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />
<h2 class="post-message">Test</h2>
</span>
So here's my fiddle
HTML
<div class="container">
<div class="cardItem">
<h1>Mouse over me</h1>
<p>Keep moving the mouse during transition</p>
<p>Also have the mouse still over where the new
paragraph will come before the transition finishes</p>
<div class="cardHoverSide">
<p>See if my hover state still
fires despite your <span>crazy</span> mouse movements</p>
<div class="cardItem">NestedCard With Hover!</div>
</div>
</div>
</div>
CSS
.container {
overflow: hidden;
height: 17em;
width: auto;
}
.cardItem {
position: relative;
float: left;
margin: 0 .35em;
border: none;
background: #444;
color: #eee;
width: 10em;
height: 17em;
-moz-transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
-o-transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
-webkit-transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
}
.cardHoverSide .cardItem {
width: 60%;
height: 50%;
}
.cardHoverSide .cardItem:hover {
background: #eee;
color: #222;
transform: initial;
}
.cardItem:hover {
-moz-transform: translate(0, -17em);
-ms-transform: translate(0, -17em);
-o-transform: translate(0, -17em);
-webkit-transform: translate(0, -17em);
transform: translate(0, -17em);
-moz-transition: transform .3s cubic-bezier(1, .01, 1, .41);
-o-transition: transform .3s cubic-bezier(1, .01, 1, .41);
-webkit-transition: transform .3s cubic-bezier(1, .01, 1, .41);
transition: transform .3s cubic-bezier(1, .01, 1, .41);
}
.cardHoverSide {
border: none;
background: #eee;
color: #444;
width: inherit;
height: inherit;
position: absolute;
bottom: -17em;
}
.cardHoverSide p span:hover {
color: red;
}
h1, h2, p {
margin: .5em .3em;
padding: 0;
}
I want the hover state of each nested element to be fired anytime the mouse is over that element. For instance when you are moving the mouse in the empty space of the nested card it doesn't seem to always trigger the hover state consistently.
The nested span tag also has some issues... don't know if I've set up the CSS incorrectly/not with best practices - or if I need to be using JS to trigger that.
Thanks for reading! All help is greatly appreciated.
Edit Updated fiddle
I'm specifically interested in when the mouse is stationary after initiating the transition - it seems on chrome the hover state does not fire on the child elements (so in the fiddle the p tag or nested panel don't change states). I've been able to consistently repeat this behavior on the updated fiddle.
I have a basic CSS transition where I rotate a pseudo ::after element and increase its width on hover. However the element transition is choppy and skips most of the animation halfway through.
Issue reproduced in a Code Pen.
I've tried using -webkit-backface-visibility: hidden; to solve the issue but I cant seem to stop the transition flash. Any ideas?
Transition css:
a {
position: relative;
text-decoration: none;
color: #db421c;
-webkit-box-shadow: inset 0px 4px 0px #fff;
-moz-box-shadow: inset 0px 4px 0px #fff;
-o-box-shadow: inset 0px 4px 0px #fff;
box-shadow: inset 0px 4px 0px #fff;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
a + a {
margin-left: 20px;
}
a::after{
width: 20px;
height: 1px;
content: " ";
background: black;
position: absolute;
-webkit-transform: rotate(90deg) translate(55%, 10%);
-moz-transform: rotate(90deg) translate(55%, 10%);
-o-transform: rotate(90deg) translate(55%, 10%);
transform: rotate(90deg) translate(55%, 10%);
webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
a:last-child::after {
content: none;
}
a:hover {
color: black;
}
a:hover::after {
width: 100%;
height: 2px;
-webkit-transform: rotate(180deg) translate(100%, -20px);
-moz-transform: rotate(180deg) translate(100%, -20px);
-o-transform: rotate(180deg) translate(100%, -20px);
transform: rotate(180deg) translate(100%, -20px);
}
I isolated the issue to the translate transformation; I wasn't sure how exactly to fix it, although I have a feeling the solution is in the transform-origin property. The only working solution I was able to come up with was to use positioning in order to move the pseudo elements. The same rotation is being used, we are just making use of the absolute positioning in order to translate the elements. This method doesn't have any apparent issues given that the parent element is relatively positioned. This method should also work for elements with varying widths.
UPDATED EXAMPLE HERE - it achives the exact same effect without the choppiness.
Instead of translate(55%, 10%), use top: 10px/right: -22px
And instead of translate(100%, -20px), use top: 22px/right: 0px
Updated CSS
a::after {
width: 20px;
height: 1px;
content: " ";
background: black;
position: absolute;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
top: 10px;
right: -22px;
}
a:hover::after {
width: 100%;
height: 2px;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
top: 22px;
right: 0px;
}
On this jsfiddle you can see that I have 6 circles: 3 on the first row and 3 on the second row.
I'd like to add some space between them and was planning to use margin-right: 5px. The issue if I do this is that the last elements (circle 3 and circle 6) will also have this extra 5px to their right which I don't want (since there's no elements next to them). Is there a workaround to that?
What I need is:
(Circle 1) 5px space (Circle 2) 5px space (Circle 3)
Thanks
HTML:
<div class="circle circlebackground">
<p>Circle 1</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
<div class="circle circlebackground">
<p>Circle 2</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
<div class="circle circlebackground">
<p>Circle 3</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
<div class="circle circlebackground clear">
<p>Circle 4</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
<div class="circle circlebackground">
<p>Circle 5</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
<div class="circle circlebackground">
<p>Circle 6</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
CSS:
.circle {
float: left;
margin-bottom: 10px;
width: 200px;
height: 200px;
border-radius: 50%;
position: relative;
box-shadow: inset 0 0 0 16px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.1);
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
.circlebackground {
background: #fff;
border:1px solid #37629B;
}
.innercircle {
position: absolute;
background: red;
width: inherit;
height: inherit;
border-radius: 50%;
opacity: 0;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-backface-visibility: hidden;
}
.circle p {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
margin: 0;
}
.innercircle p {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
margin: 0;
opacity: 1;
-webkit-transition: all 1s ease-in-out 0.4s;
-moz-transition: all 1s ease-in-out 0.4s;
-o-transition: all 1s ease-in-out 0.4s;
-ms-transition: all 1s ease-in-out 0.4s;
transition: all 1s ease-in-out 0.4s;
}
.circle:hover {
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 1px 2px rgba(0, 0, 0, 0.1);
}
.circle:hover .innercircle {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.circle:hover .innercircle p {
opacity: 1;
}
.clear {
clear: both;
}
You can use this type of css if you really want to give margin-right.
.circle {
float: left;
margin-bottom: 10px;
width: 200px;
height: 200px;
border-radius: 50%;
margin-left:5px; /*added*/
position: relative;
box-shadow: inset 0 0 0 16px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.1);
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
.circle:nth-of-type(3n+0) {
margin-right:0px;
}
jsfiddle link
Make a class with margin-right: 5px and that add you in the circle where you want.
Here the JSfiddle
.circle_5px_marging {
margin-right: 5px;
}
add another class for your last div and there mention margin-right:0;
MARK-UP::
<div class="all_circles">
</div>
<div class="all_circles">
</div>
<div class="all_circles last_circle">
</div>
CSS::
.all_circles{
margin-right:5px;
}
.last_circle{
margin-right:0;
}
now in this example .all_circles is aplied to every div which have margin-right:5px; and change it for the last div by adding an extra class where margin-right:0;
note:: in this case the additional style, i.e. .last_circle must be defined after defining .all_circles because here .last_circle will override the margin property
of .all_circles
I put an image on :after, with a translation on :hover. It makes other unrelated elements move on Chrome, with OS X (Firefox: unresponsive, and Safari : doesn't support transition effect)
I tried without transition, works fine.
I have this on several elements, and they all have this same problem as long as transition and :after are involved.
Here's the html:
See the project
and the css:
.btn-call-to-action {
background: #8e8287;
margin-bottom: 15px;
color: #f5f3e2;
padding: 10px 70px 10px 10px;
margin-top: 6px;
line-height: 1;
display: inline-block;
position: relative;
border-bottom: none;
border-radius: 2px;
white-space: nowrap; }
.btn-call-to-action:after {
content: url('../img/general-white-arrow.svg?1370787761');
position: relative;
display: inline-block;
position: absolute;
top: 8px;
width: 35px;
padding-left: 15px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out; }
.btn-call-to-action:hover:after {
-webkit-transform: translatex(6px);
-moz-transform: translatex(6px);
-o-transform: translatex(6px);
-ms-transform: translatex(6px);
transform: translatex(6px); }
and the live version here.