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.
Related
I have a simple overlay of text over an image, darkening the background in the process. I used transition with ease-in-out, but it doesn't seem to ease out properly.
I know that the ease-in-out should be applied to the thing itself, and not its pseudo of :hover, but it doesn't seem to want to work. I have tried many ways, moving it around, deleting stuff, adding stuff, but nothing seems to make sense.
I notice the text do ease out fine, but the background with rgba opacity doesn't co-operate. It just snaps back :(
Do refer to a live version at http://g4stly.com/staff.html to know what I'm talking about, specifically.
Thanks in advance!
My code is as follows:
#g4stly
{
background-image: url('http://g4stly.com/images/users/g4stly.jpg');
}
.textFrame
{
text-align: center;
font-size: 20px;
color: #DDAA49;
text-decoration: none;
background-repeat: no-repeat;
background-size: cover;
border-radius: 30%;
width: 250px;
height: 250px;
}
.textFrame p
{
opacity: 0;
height: 75%;
margin: 0;
border-radius: 30%;
transition: opacity 300ms ease-in-out;
}
.textFrame p a
{
text-decoration: none;
color: #976649;
font-size: 25px;
}
.textFrame:hover p
{
opacity: 1;
background: rgba(0,0,0,0.8);
}
.textFrame p:first-child
{
padding: 25% 0 0 0;
}
<div id="g4stly" class="textFrame textFrameLeft">
<p>g4stly<br><br>
Owner of everything g4stly related<br>
Basically, the boss.</p>
</div>
I noticed you updated the code. Looks like your issue has already been solved.
The .textFrame p was only applying transition for opacity, so you couldn't see the background transition. I seed you added background .... to the transition, you could also do:
transition: all 1000ms ease-in-out;
Another option would be to move the rgba background to inside the .textFrame p, so the background wouldn't suddenly disappear, fading out along with the rest of the element.
Hopefully this helps you understand the cause :)
You had a comma where there should have been a semicolon.
transition: background 1000ms ease-in-out;
#g4stly {
background-image: url('http://g4stly.com/images/users/g4stly.jpg');
}
.textFrame {
text-align: center;
font-size: 20px;
color: #DDAA49;
text-decoration: none;
background-repeat: no-repeat;
background-size: cover;
border-radius: 30%;
width: 250px;
height: 250px;
}
.textFrame p {
opacity: 0;
height: 75%;
margin: 0;
border-radius: 30%;
transition: background 1000ms ease-in-out;
transition: opacity 1000ms ease-in-out;
}
.textFrame p a {
text-decoration: none;
color: #976649;
font-size: 25px;
}
.textFrame:hover p {
opacity: 1;
background: rgba(0, 0, 0, 0.8);
}
.textFrame p:first-child {
padding: 25% 0 0 0;
}
<div id="g4stly" class="textFrame textFrameLeft">
<p>g4stly<br><br> Owner of everything g4stly related<br> Basically, the boss.</p>
</div>
I have a hover effect that moves a new background-color over an existing one, making it appear the background is fading to the right. For some reason a bit of the background-color is showing on the left side of the blocks.
The only thing I could think of was my black border, but I have a border set in the elements natural style.
Does anyone know what is causing this?
#service-tabs-left {
float: left;
margin-left: 150px;
}
#service-tabs-right {
float: right;
margin-right: 150px;
}
.service-tab-block {
position: relative;
font-size: 1.6em;
padding: 1em 25px;
text-align: center;
display: block;
margin: 30px 0;
cursor: pointer;
border: 1px solid #838557;
background-image: linear-gradient(to right, #000 50%, #838557 50%);
background-size: 200% 100%;
background-repeat: no-repeat;
background-position: bottom right;
transition:width 0.2s ease;
-webkit-transition:width 0.2s ease;
}
.service-tab-block.active {
background: #000;
color: #FFF;
}
.service-tab-block:hover {
-webkit-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
background-position: bottom left;
color: #FFF;
border: 1px solid #000;
}
<div id="service-tabs-left">
<h1 class="service-tab-block" id="service_tab1">DEMOLITION</h1>
<h1 class="service-tab-block" id="service_tab2">ENVIRONMENTAL SOLUTIONS</h1>
<h1 class="service-tab-block" id="service_tab3">CONCRETE CRUSHING</h1>
</div>
<div id="service-tabs-right">
<h1 class="service-tab-block" id="service_tab4">ASSET RECOVERY</h1>
<h1 class="service-tab-block" id="service_tab5">SCRAP METAL RECYCLING</h1>
<h1 class="service-tab-block" id="service_tab6">FOUNDATION REMOVAL</h1>
</div>
You have to change the background-size property from 200% to 201%. The extra 1% gives the cover you need.
https://jsfiddle.net/o7sxoton/
I fixed it by changing the linear gradient for black to 49% on .service-tab-block
BTW , this is one of those issues you can see by adjusting your browsers zoom for anyone who was wondering.
.service-tab-block {
background-image: linear-gradient(to right, #000 49%, #838557 50%);
Set this:
.service-tab-block{
box-sizing:border-box;
-moz-box-sizing:border-box;
}
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?
I'm trying to do a simple animation using only css. The idea is that when I hover a social icon it will seem like it's lifting up. I managed to do that but now i want to use "border" to seem like it's the icon's shadow. I reduced the thickness of the border on hover but I wanted to make it seem more realistic and somehow reduce the width of the border when hovering over. Any ideas?
Here is my fiddle: http://jsfiddle.net/Iulius90/sck4Lzz9/
html
<div>
<img src="http://fc05.deviantart.net/fs70/f/2012/204/7/b/logo_skype_by_jackal807-d58ctxc.png">
</div>
css
div {
width:200px;
height:200px;
background-color:tomato;
}
img {
width: 100px;
height:100px;
margin: 50px;
border-bottom: 3px solid #222;
transition: all 0.35s ease;
}
div img:hover {
margin-top: 22px;
padding-bottom:28px;
border-bottom: 1px solid #222;
transition: all 0.35s ease;
cursor: pointer;
}
You can simply use a solid linear gradient as a background image, and manipulate its dimensions upon hover. Note: You might want to use vendor prefixes to generate CSS gradients that are cross browser compatible.
img {
background-image: linear-gradient(to top, rgba(0,0,0,.5) 0%, rgba(0,0,0,.5) 100%);
background-position: center bottom;
background-repeat: no-repeat;
background-size: 100% 3px;
width: 100px;
height:100px;
margin: 50px;
transition: all 0.35s ease;
}
div img:hover {
background-size: 50% 1px;
margin-top: 22px;
padding-bottom:28px;
transition: all 0.35s ease;
cursor: pointer;
}
http://jsfiddle.net/teddyrised/sck4Lzz9/26/
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