Problem with underlining text using box-shadow - html

I need to underline some words in a heading. I have the following code from this excellent article: https://css-tricks.com/styling-underlines-web/
I'm using two box-shadows to create a 1px underline.
.underline {
box-shadow:
inset 0 calc(-0.2em + 1px) rgb(255, 255, 255),
inset 0 -0.2em rgb(0, 0, 0);
}
<h1>I can help you <span class="underline">create positive impact.</span></h1>
It works fine. Apart from on an iPhone there is sub-pixel grey border around the edge of the white inset box shadow. As if the white box is not quite covering the black box. See screen grab:
I note that the code provided on CSS Tricks website includes
.underline {
background-size: 1px 1em;
display: inline;
}
I've also tried with this additional code, but it doesn't make any difference. (I think this code is superflous. It doesn't do anything?).
So... how do I stop this grey outline from displaying?
I've tried adding a shadow to the outside bottom edge of the box. To 'mask' the grey line, but it has not worked:
.underline {
box-shadow:
0 2px rgb(255, 255, 255),
inset 0 calc(-0.2em + 1px) rgb(255, 255, 255),
inset 0 -0.2em rgb(0, 0, 0);
}

It's a known bug in iOS.
For workaround, you can simply put an mask as overlay:
-webkit-mask-image: -webkit-radial-gradient(white, black);
.underline {
-webkit-mask-image: -webkit-radial-gradient(white, black);
box-shadow:
inset 0 calc(-0.2em + 1px) rgb(255, 255, 255),
inset 0 -0.2em rgb(0, 0, 0);
}

Related

How to style indeterminate progress bars?

I need progress bars on this tool I'm building, but indeterminate ones are giving me trouble. To create the usual one, I followed this guide: https://css-tricks.com/html5-progress-element/.
The default looks like this in my view:
This doesn't work with the styles of the rest, so I wanted to change it. The guide suggests to use progress:not([value]) {} to target indeterminate progress bars, but it doesn't really work. The container gets styled, but the moving bit just disappears:
What's the proper way to do this?
This is what I tried to apply:
progress:not([value]) {
-webkit-appearance: none;
appearance: none;
}
progress:not([value])::-webkit-progress-bar {
background-color: #EEEEEE;
border-radius: 2px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
}
progress:not([value])::-webkit-progress-value {
background-image: -webkit-linear-gradient(
-45deg, transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%),
-webkit-linear-gradient(
top,
rgba(255, 255, 255, 0.25),
rgba(0, 0, 0, 0.25)),
-webkit-linear-gradient(left, #09C, #F44);
border-radius: 2px;
background-size: 35px 20px, 100% 100%, 100%, 100%;
}
I found this question and there's an answer, but the bit for indeterminate progress bars looks the same as what I tried to do.

Backdrop Filter is not applied in CSS & HTML

I am trying to make a glassmorphism effect and my problem is that the webkit backdrop filter is not applied to the background of the div.
the css code:
.glassmorphism {
background: rgba( 255, 255, 255, 0.20);
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37);
-webkit-backdrop-filter: blur(10em);
backdrop-filter: blur(10em);
border-radius: 10px;
border: 1px solid rgba( 255, 255, 255, 0.18);
}
html:
<div id="content__body" class="glassmorphism"></div>
And I get this error in chrome:
invalid property value
Edit;
I just found out the problem myself:
I had two glassmorphism divs over eachother. For some reason that lead to a cancelation of the effect. In short: The styling above works but not for stacked divs
Use 10px instead of 10em
and your backdrop filter is working.

Is it possible to have div background with opacity but with gradient some pixel borders?

I have a div with 0.5 transparency. This acts as a darkening rectangle over a bigger background slider image (an outer div) to make the text more readable over the slider background picture.
<div class="darken-rectangle">
<!-- inner text container divs go here -->
</div>
CSS:
.darken-rectangle {
padding: 30px 30px 30px 30px;
background-color: rgba(0, 0, 0, 0.5);
}
This works great, however I would like to a few pixel (3px-6px) gradient border for the rectangle which drives the alpha from the outer light to the inner darken.
Unfortunately I can not find how to do this, even does not know is it possible with pure CSS, or do I have to create 4 png images for the 4 "border and arrange the layout?
I think what you want is box-shadow, see jsFiddle
HTML
<div class="darken-rectangle">
Test Text
</div>
CSS
.darken-rectangle {
/* ... */
background-color: rgba(0, 0, 0, 0.5);
color: white;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 1);
}
.darken-rectangle {
padding: 30px 30px 30px 30px;
background-color: rgba(0, 0, 0, 0.5);
box-shadow: 0px 0px 5px rgba(0, 0, 0, 1);
border-radius: 3px;
}

CSS inset and out box shadow

I need inset and outer shadow at a box for a menu.
How can i do that?
Here is my CSS:
li.menu-list:hover {
border:solid 0.1rem white;
background-color: rgba(26, 67, 119, 0.8);
box-shadow: 0 0 1rem 0.2rem white;
box-shadow: 0 0 1rem 0.3rem white inset;
}
You can't do this as you are overwriting your original value. What you should do is this:
box-shadow: 0 0 1rem 0.2rem white, 0 0 1rem 0.3rem white inset;
By adding another box-shadow declaration, you are actually resetting the box shadow and implementing another one, so only one shows up. CSS3 has a lot of these new-fangled options and they can all be chained together using commas to separate them.

How to box-shadow inset on just the Left, Bottom, Right -- not the top?

I have the following box-shadow inset css3 styling:
box-shadow: inset 0 0 10px 0 rgba(255, 255, 255, 1);
The inset styling appears on all 4 sides of the box but I do not want styling on the top. How can I remove the styling from the top but keep the styling on the Left, Bottom, Right?
Thanks
This is what you want:
.right-left-bottom-shadow {
box-shadow: 5px 0 5px -5px #CCC, 0 5px 5px -5px #CCC, -5px 0 5px -5px #CCC;
}
The first one is left, second bottom and last the shadow for the right side. This looks really nice if your border has color #CCC.
You can't do that with just box-shadow so far, but you can composite box-shadow with other possibilities like overflow: hidden. For example, you can push the top shadow outside of parent element and hide that part with overflow: hidden.
See this demo: http://jsfiddle.net/CatChen/Fty2N/3/
No CSS method I know for this but following can be a work around (not a perfect solution)
<div id="mydiv">
<div class="workaround"></div>
</div>
CSS
#mydiv {
background-color:#f00;
height:100px;
width:100px;
box-shadow: inset 0 0 10px 0 rgba(255, 255, 255, 1);
padding:0 2px;
}
#mydiv .workaround {
background-color:#f00;
width:100%;
height:10px;
}
Check Fiddle http://jsfiddle.net/bZF48/17/