CSS3 Image rotate overlay's over my text [closed] - html

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm trying to get a background image to rotate when I hover over it. But at the same time I want some link text over top of the picture to NOT rotate.
I have it semi working, but when the image rotates the text get's hidden behind it. and sometimes you will hover over the link, and the image doesn't rotate. Is there a way to accomplish this?
JS Fiddle: http://bit.ly/1b9bpiJ
Dev Site: http://briggs.honeycombsites.com/

A slight modification to the excellent answer of Zeaklous.
To avoid the counter-rotation of the text, do not rotate the base div. Place the background in a pseudo element and rotate this.
div.button {
width:130px;
height:130px;
position:relative;
float: left;
margin-right: 20px;
overflow:hidden;
}
div.button:after {
content: "";
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
background: url('http://briggs.honeycombsites.com//wp-content/themes/briggs/images/btn_contact.png');
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
-o-transition-duration: 0.5s;
transition-duration: 0.5s;
z-index: -1;
}
.button:hover:after {
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
}
div.button a {
color: #CFCAB4;
font-size: 24px;
line-height: 26px;
text-align: center;
text-shadow: 1px 1px 1px #333333;
width: 100%; height:80%;
text-transform: uppercase;
position:absolute;
top:50%; margin-top:-40%;
left:50%; margin-left:-50%;
}
div.button:hover a {
color: #fff;
}
div.button a span {
border-bottom: 1px solid #CFCAB4;
display: inline-block;
font-size: 12px;
line-height: normal;
margin-bottom: 7px;
text-shadow: none;
}
updated demo
In the above answer, I forgot the unprefied transform in the after
.button:hover:after {
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
transform:rotate(360deg);
}
Also, for some reason, the design breaks in firefox and IE; the font of the span needs to be set a little bit higher:
edited demo

I understand why you set up your code this way, but transform has some interesting unintentional effects at times. In your case it's affecting the z-index somehow and I'm not sure exactly how to fix it
With that being said, here's how I'd do it, which is simpler to me. It involves putting the text inside the rotating element, but rotating the text in the opposite direction at the same time in order to keep it upright
/* Updated HTML */
<div class="button">
<span>Contact Us</span>1.800 444.1515
</div>
/* CSS */
div.button {
width:130px;
height:130px;
position:relative;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
-o-transition-duration: 0.5s;
transition-duration: 0.5s;
float: left;
margin-right: 20px;
overflow:hidden;
background: url('wp-content/themes/briggs/images/btn_contact.png');
}
div.button:hover {
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
}
div.button a {
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
-o-transition-duration: 0.5s;
transition-duration: 0.5s;
color: #CFCAB4;
font-size: 24px;
line-height: 26px;
text-align: center;
text-shadow: 1px 1px 1px #333333;
width: 100%; height:80%;
text-transform: uppercase;
position:absolute;
top:50%; margin-top:-40%;
left:50%; margin-left:-50%;
}
div.button:hover a {
color: #fff;
-webkit-transform:rotate(-360deg);
-moz-transform:rotate(-360deg);
-o-transform:rotate(-360deg);
}
div.button a span {
border-bottom: 1px solid #CFCAB4;
display: inline-block;
font-size: 12px;
line-height: normal;
margin-bottom: 7px;
text-shadow: none;
}
Demo here
Let me know if you have any questions about my method

Related

CSS integration with HTML [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I have created a separate CSS file for a tool tip as below.
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip:hover p{
display:block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p{
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 300px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip p:before{
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.help-tip p:after{
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}
#-webkit-keyframes fadeIn {
0% {
opacity:0;
transform: scale(0.6);
}
100% {
opacity:100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}
From this file calling the .help-tipclass from that in html file as below. I am expecting the tool tip to be shown which is not happening as expected. Earlier I had written css code in same html file under style section but then moved css code to separate file.
<div class="domtooltip_style.help-tip">
<p><b>Deal-O-Matic (DOM)</b> has implemented multiple controls and safeguards for deal creation to ensure deal quality and to ensure that automatically created deals meet retail teams’ business requirements.<br>
<b>Contribution Profit (CP) Check</b>: DOM ensures that Deals created automatically are CP positive through the duration of the deal and ends deals that turned CP negative.</p>
</div>
Appreciate if someone can correct me to call class from CSS file in HTML file.
Inside the html you separate multiple classes with a space
so use
<div class="domtooltip_style help-tip">

Increasing hover area of CSS circle [duplicate]

This question already has answers here:
Bigger area for hovering multiple small circles
(3 answers)
Closed 7 years ago.
I have a page with little elements with border-radius set to 50%, so they show up as little dots:
CSS:
.star {
width: 5px;
height: 5px;
background-color: rgb(236, 236, 236);
position: absolute;
border-radius: 50%;
transform: scale(1);
display: block;
transition: 0.25s ease-in background-color, 0.25s ease-in opacity, 0.25s ease-out transform;
cursor: pointer;
}
Each of these has a hover action that brings up a certain pop-up. Now however, there's an issue where hovering (at least in the browsers I've tested for) is a game of find the pixel.
Is there a "trick" to add an invisible border or so to the dots to make them more selectable without hunting for pixels?
Setting border to say 2px solid transparent just makes the circles bigger in my tests, and CSS outline does not produce a :hover state or mouseenter event.
Use a pseudo-element to increase the "hit area"
body {
background: #000;
}
.star {
width: 5px;
height: 5px;
background-color: rgb(236, 236, 236);
position: absolute;
left: 50%;
top: 50%;
border-radius: 50%;
transform: scale(1);
display: block;
transition: 0.25s ease-in background-color, 0.25s ease-in opacity, 0.25s ease-out transform;
cursor: pointer;
}
.star::before {
content: '';
position: absolute;
border-radius: 50%;
width: 500%;
height: 500%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index:-1;
border:1px solid green; /* for demo purposes */
}
.star:hover {
background: #f00;
}
<div class="star"></div>
Try this:
.star {
width: 10px;
height: 10px;
padding:10px;
background:#000;
border-radius:50%;
background-clip:content-box; /* <- key point*/
}
.star:hover { background-color:#f00; }
<div class="star"></div>
Increased padding will give you larger hit margins.
Your transparent border method is fine and works the best in all browsers ;)
Just add:
background-clip: padding-box;
To make sure the background does not show under the borders.
Add circle under each star and give it a black background ex;
<div class="starWrapper">
<div class="star"></div>
</div>
.star { top:3px;
left:3px;
width: 5px;
height: 5px;
background-color: rgb(236, 236, 236);
position: absolute;
border-radius: 50%;
transform: scale(1);
display: block;
cursor: pointer;}
.startWrapper{
position:absolute;
background:#000;
width:8px;
height:8px;
border-radius: 50%;}

Making text disappear when not hovering over it

I am trying to recreate an effect I saw on "TheButton" subreddit. You can see that next to most usernames there is a colored dot that when hovered over expands and reveals some underlying text.
Using their CSS as a starting point, I can recreate this effect but my issue is that the underlying text I have does not collapse, so I never achieve a "dot" shape while the user is not hovering.
Here's my CSS:
* {
font: normal x-small verdana,arial,helvetica,sans-serif;
}
.flair {
min-width: 12px;
max-width: 12px;
height: 12px;
line-height: 12px;
border-radius: 12px;
border: none;
overflow: hidden;
padding: 0;
vertical-align: middle;
font-size: 10px !important;
-webkit-transition:all 0.3s;
transition: all 0.3s;
-webkit-transition-delay: 1s;
transition-delay: 1s;
position: relative;
}
.flair:hover {
max-width: 500px;
padding: 0 5px;
color: #fff;
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
.flair-no-press {
background:#888;
color:#888;
}
And here's my HTML:
<span class="flair flair-no-press" title="non presser">non presser</span>
Here's a jsfiddle showing what this looks like. Once again my intended effect is simply making the dot collapse entirely when not being hovered over like they have.
What am I missing here?

CSS Mask-image won't work

I am trying to mask image (with text shadow) using CSS property -webkit-mask-image.
I understand that I can use background-clip however I need to do this using only mask-image
property for some reason. However upon trying it out I was stack with some CSS codes.
here's my CSS code:
#masking h1, span.mask-text {
font-size: 230px;
font-family: 'Lilita One', sans-serif;
text-align: center;
margin: 0 auto;
padding: 0;
-webkit-text-fill-color:transparent;
position:absolute;
left: 100px;
}
#masking h1 {
text-shadow: 3px 3px 0px #34495e;
z-index:2;
}
span.mask-text {
-webkit-mask-image: url('http://halloweenmaternitycostumes.com/wp-content/uploads/2014/11/paper.jpg') no-repeat center center;
background-size: cover;
z-index:5;
-webkit-transition:all 0.7s ease;
-moz-transition:all 0.7s ease;
-o-transition:all 0.7s ease;
transition:all 0.7s ease;
}
span.mask-text:hover{
cursor: pointer;
-webkit-mask-image: ('http://halloweenmaternitycostumes.com/wp-content/uploads/2014/11/paper-hover.jpg') no-repeat center center;
background-size: cover;
z-index:5;
}
span.mask-text:after {
content: 'Mask Text';
text-transform: uppercase;
}
Here's an image what I am trying to do:
Here's the jsFiddle version: http://jsfiddle.net/cmtr3txu/2/
If you could show me the solution using jsFiddle that would be great.
I updated your code here:
http://jsfiddle.net/cajvgkxt/3/
To add a background to the text, do as follows... Note: background must come before clipping!
span{
font-size: 50px;
font-family: Helvetica, Arial;
background: url(http://www-users.cs.umn.edu/~interran/texture/lic2.gif);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<span>Text</span>
Your code does two things novel-- animation and text-shadow. For the text-shadow, I made sure that your span and h1 both had font-weight:bold (by default, one is bold and the other is not). For the animation, I left it up to you to customize. You'll need to change the easing and background position.

CSS3 Menu Animation Flicker

I've created a simple hamburger menu that transforms into a plus sign when the user hovers over it but there's an annoying flicker that occurs on hover. Is it possible to increase the hover region around the entire hamburger in CSS3 so that the flicker doesn't occur?
Here's the codepen link:
http://cdpn.io/LJHpe
As you likely know the flickering is due to the elements starting and stopping being hovered. There are several ways to fix this, the path I chose to do so is to make it one element instead of two (:
<span class="menu">MENU</span>
body {
background:#EDDE45;
position:relative;
margin-left:50%;
top:50px;
}
.menu {
position:relative;
top:50px;
padding-top:3em;
font-family: arial,verdana;
font-size:18px;
color:black;
cursor:default;
}
.menu:before { /* The top two lines */
content:'';
position: absolute;
left: -1em;
top: 0;
width: 5em;
height: .5em;
border-top:0.5em solid black;
border-bottom:0.5em solid black;
transition:transform 0.25s ease-in, border-bottom .2s;
}
.menu:after { /* The third line */
content:'';
position: absolute;
left:-1em;
top:2em;
width:5em;
height:0.5em;
background:black;
transition:all 0.25s ease-in;
}
.menu:hover {
cursor:pointer;
}
.menu:hover:before {
transform:scale(0.8);
border-bottom:0.5em solid rgba(255,255,255,0);
}
.menu:hover:after {
transform:scale(0.8) rotate(90deg);
top:0em;
}
Demo
Let me know if you have any questions!