CSS Embossed (Inset) Text - css

I'm trying to give my headings a nice embossed look. It works great in Chrome, but Firefox bows out. How can I make this effect work in both? Here's the fiddle:
https://jsfiddle.net/7p15s3nv/
And my CSS:
h1 {
background-color: #565656;
color: transparent;
text-shadow: 0px 2px 3px rgba(255,255,255,0.5);
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
}
Thanks for any help.

maybe without background-clip, but a more 'classical' approach ?
h1:first-of-type {
background-color: #565656;
color: transparent;
text-shadow: 0px 2px 3px rgba(255,255,255,0.5);
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
}
h1+h1 {
color: rgba(255,255,255,0.4);
text-shadow: 0 -2px rgba(0,0,0,0.6);
}
<h1>Hello there! webkit</h1>
<h1>Hello there! FF ?</h1>
fiddle to play with https://jsfiddle.net/7p15s3nv/5/
to test side by side in chrome and any other browser such as IE or FF

Is this the desired output?
h1{
font-size: 100px;
color: rgba(255,255,255,0.4);
text-shadow: 1px 2px 3px #eee, 0 0 0 #000, 1px 2px 3px #eee;
}
<h1>This is text</h1>
UPDATE
This update is to cover the last comment from question author:
h1 {
margin-top: 0;
font-size: 200px;
color: rgba(255,0,0,0.8);
text-shadow: 1px 2px 0 #EEE, 0 0 0 #000, 1px 2px 0 #EEE;
}
<h1>This is text</h1>

While background-clip is a valid CSS3 property, the text value in non-standard. That's why it does not work in most browsers.
A trick that might work for you is a combination of semi-transparent text (with rgba) and text-shadow like this:
h1 {
color: rgba(0,0,0, 0.6);
/* #FFF should be the same as background color of the text */
text-shadow: 3px 3px 6px #fff, 0 0 0 #666, 3px 3px 6px #fff;
}
<h1>TEXT</h1>

I think that the only solution is to duplicate the text in a pseudo.
Not very easy to maintain, but it can work
In case you go with this solution, to make it easier to maintain would be to set the text in an attr in the element, and use this attr for the content of the pseudo
.demo {
font-size: 200px;
color: darkgreen;
position: relative;
}
.demo:after {
content: "Hello";
position: absolute;
left: 0px;
top: 0px;
color: transparent;
text-shadow: 0px 20px 30px rgba(255, 255, 255, 0.91);
}
<div class="demo">Hello</div>

Related

Border colors of button:active not working as set out

I have styled a button which switches colors of its' borders depending on if its clicked or not (button:focus, button:active). The issue is that the colors do not change on button:focus, only on button:active. Other changes (such as adjusting background picture) of the state of button:focus works just fine.
Here's the CSS:
.buttonrod {
background:url(https://i.imgur.com/MtHnHtP.png) no-repeat;
background-position: 0px -30px;
position:relative;
background-size:cover;
width: 150px;
height: 150px;
text-decoration: none;
display: inline-block;
margin-left: 120px;
font-size: 12px;
cursor: pointer;
font-weight: bold;
border-color:transparent;
color: #E4B018;
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
border-color: #757575 #2a2a2a #2a2a2a #757575;
}
.buttonrod:focus {
border-color: #2a2a2a #757575 #757575 #2a2a2a;
background-position: 0px -29px;
outline: none;
}
.buttonrod:active {
border-color: #2a2a2a #757575 #757575 #2a2a2a;
background-position: 0px -29px;
outline: none;
}
For some reason, the color of the border in the :focus state defaults to a light grey all around, instead of the different shadings I have attached. It's driving me insane. I added the line to adjust the image to create the illusion of a pressed button, and that worked both for focus and active. I am clueless, and any help is appreciated.

how can I get this kind of box shadow or outline?

Is this a box shadow or an outline? I'm confused because outlines can't have radius property and box shadows have blur effect.
That can be a combination of border and box-shadow and outline: none.
I have added the border and box-shadow to default state, if needed we can move that to :focus
body {
padding: 10px;
zoom: 250%;
}
.custom {
width: 100%;
height: 30px;
border-radius: 5px;
border: 2px solid #0000ff;
box-shadow: 0 0 0 2pt rgb(0 0 255 / 30%);
}
.custom:focus {
outline: none;
}
<input type="text" class="custom">
Use an outline with a rgba color on an input with a border radius:
input {
border: 1px solid #ae11fc;
border-radius: 0.5rem;
font-size: 1rem;
height: 2rem;
}
input:focus {
outline: #ae11fc44 solid 0.2rem;
}
Checkout out this fiddle
You can achieve the required styling by adding the following properties to your input style. You can play around it here: https://codepen.io/taleyamirza/pen/ExmzYJr
input:focus {
outline-color: #6c8afc;
border-color: #9ecaed;
box-shadow:0 0 10px #6c8afc;
-moz-box-shadow: 0px 0px 4px #6c8afc;
-webkit-box-shadow: 0px 0px 4px #6c8afc;
}

How to create inset text shadow?

How can I create inset shadow on text? Here is what I am trying to achieve
I am creating this in Figma, on text I have added both drop shadow and text shadow. It seems that Figma only shows source code for drop shadow. Can I achieve inner shadow as well? Values in Figma are these:
x:0
y:4
blur:4
spread:0
color: #000
percentage:25%
h1 {
font-size: 6rem;
margin-bottom: 1rem;
text-shadow: -1px -1px 7px rgba(0,0,0,.2), -1px -1px 2px rgba(255,255,255,.6);
color: #C92929;
text-align: center;
}
<h1>Lorem ipsum</h1>
In CSS you can experiment with transparency of text color and its shadow.
For example:
h1 {
color: rgba(201, 41, 41, 0.8);
text-shadow: 0px 4px 4px #fff, 0 0 0 #000, 0px 4px 4px #fff;
font-size: 6rem;
margin-bottom: 1rem;
text-align: center;
}
<h1>Lorem ipsum</h1>
I think, the main problem is calculate that values of colors, to receive advisable effect.
We make a blurred white text-shadow, and a black text-shadow, while making the color of the text transparent. This can give the illusion that the text-shadow is inset... There is no such property, though.
h1 {
color: transparent;
text-shadow: 0px 4px 4px #fff, 0 0 0 #000, 0px 4px 4px #fff;
font-size: 6rem;
margin-bottom: 1rem;
text-align: center;
}
<h1>Lorem ipsum</h1>
You can try with transparency as subject here and the code below:
I know result is not the one you expect, because I did not change your shadow. But this the way I use transparantrency that is important.
h1 {
font-size: 3rem;
margin-bottom: 1rem;
text-shadow: 0px 0px 7px rgba(0,0,0,.2), 0px 0px 2px rgba(255,255,255,.2);
text-align: center;
background: white;
}
span{
background: #C92929;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
display:block;
}
<h1><span>Lorem Ipsum</span></h1>

Chrome not printing out text shadow #media print

I have just modified some td's in a table because I am using a split colored backgrounds and my problem is that when I use a half white and half brown background, the text is not visible unless I set a text-shadow
This is how it looks when printed out on Safari. As you can see the text has a border shadow. This is all set in my code bellow.
border-radius: 5px;
border:1px;
border-color:#000;
-webkit-text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
-webkit-print-color-adjust: exact;
font-family: Arial, Helvetica, sans-serif;
font-size:40px;
text-align: center;
border-style: solid;
padding: 0px;
color: #000;
width: 80px;
height: 80px;
vertical-align: -52px;
font-weight: bold;
-webkit-print-color-adjust: exact;
}
When I try and print it out on Chrome, All Works the same a safari apart from the text shadow. Should be read mlk.
Has anyone been faced to this problem before?
Try something like this #media Print text-shadow under Chrome. see snippet below.
.shadow {
border-radius: 5px;
border: 1px;
border-color: #000;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
font-family: Arial, Helvetica, sans-serif;
font-size: 40px;
text-align: center;
border-style: solid;
padding: 0px;
color: #fff;
width: 80px;
height: 80px;
vertical-align: -22px;
font-weight: bold;
background: linear-gradient(to right, #ffffff 0%,#ffffff 48%,#752201 52%,#752201 100%);
}
/*
this is the part you are interested in
*/
#media print {
#media print and (-webkit-min-device-pixel-ratio: 0) {
.shadow {
-webkit-filter: drop-shadow(-1px 0 black) drop-shadow(0 1px black) drop-shadow(1px 0 black) drop-shadow(0 -1px black);
}
}
/*
additional print specific css styling can go here
*/
}
<div class='shadow'>mlk</div>

glow around div with border and color

Is there any way to add a glow around the div? Look at twitter login and how there is a blue glow around the input box, can that be done for the div?
CSS3 can do that
-webkit-box-shadow:0 0 20px blue;
-moz-box-shadow: 0 0 20px blue;
box-shadow:0 0 20px blue;
Working JSFiddle.
Here is the complete code to style a div exactly like the twitter login input. The styles for the blue border are the box-shadow and border styles for the selector div[contenteditable]:focus. Live demo here (click).
Markup:
<div contenteditable="true">Username or email</div>
CSS:
div[contenteditable]:focus {
border: 1px solid rgb(86, 180, 239);
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.05) inset, 0px 0px 8px rgba(82, 168, 236, 0.6);
}
div[contenteditable] {
width: 97%;
max-width: 280px;
margin-right: 10px;
font-family: Arial,sans-serif;
-webkit-box-shadow: inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.075);
box-shadow: inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.075);
display: inline-block;
padding: 4px;
margin: 0;
outline: 0;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 3px;
font-size: 13px;
line-height: 20px;
}
As shown before, use css: focus, border and box-shadow.
If using IE, make sure <doctype> is specified.
.text:focus {
border: 1px solid #07c;
box-shadow: 0 0 10px #07c;
}
jsFiddle example.
Also you will face some problem with Internet Explorer while dealing this issue. IE-9 How ever supports box-shadow but the previous versions don't, Check it out here for making it work in all versions of IE

Resources