Issue with opacity and layers - html

I'd like to apply opacity to the white rectangle on top of the screen (.header) but for some reason the opacity is applied to all the elements (logo and menu items). I tried to play with z-index but that didn't help. How could I fix this? Many thanks
http://jsfiddle.net/ycLqqsgr/1/
body {
background-image: url('http://lorempixel.com/output/sports-q-c-1141-1113-2.jpg');
}
.header {
z-index: 999;
position: absolute;
background: #fff;
opacity: 0.4;
top: 35px;
right: 0;
left: 0;
margin: 0 auto;
width: 90%;
max-width: 1200px;
}
.header-wrapper {
padding: 54px 60px;
}
.header-logo {
position: absolute;
margin-top: -40px;
}
.header_nav {
float: right;
clear: none;
font-family: 'Maven Pro', sans-serif;
font-weight: normal;
}
.header_nav-wrapper {
list-style: none;
}
.header_nav-item {
margin-left: 22px;
float: left;
clear: none;
}
.header_nav-item-a {
color: #474032;
text-decoration: none;
}
.header_nav-item-a:hover {
color: #eee;
}
.header_nav-item-a--btn {
padding: 16px 18px;
border-radius: 5px;
border: 1px solid #474032;
background-color: transparent;
}
.header_nav-item-a--donate {
margin-top: -18px;
}
.header_nav-item-a--btn:hover {
border: 1px solid #eee;
}

That's a common problem. The opacity is applied to all child elements. A workaround is to use rgb color codes. I will give an example with a black background at 0.6 opacity.
/* Fallback for web browsers that don't support RGBa */
background-color: rgb(0, 0, 0);
/* RGBa with 0.6 opacity */
background-color: rgba(0, 0, 0, 0.6);
/* For IE 5.5 - 7*/
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
/* For IE 8*/
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000,endColorstr=#99000000)";

Remove the opacity: 0.4 and the background-color:#FFF from .header and instead apply:
.header {
background-color:rgba(255,255,255,0.4);
background-color:rgb(133,231,211);
}
Opacity styles the entire element and its descendants, setting the background color to contain an alpha component fixes this.
Using my translucent color equivalence tool, you can find an appropriate fallback color for browsers which do not support alpha transparency (although today, almost all modern browsers have support for this feature, if they don't, it's likely your site will appear broken regardless). Simply mix white with 0.4 opacity against your green background and you'll be able to reasonably simulate a translucent color.
I don't have access to your background image color, but given it's roughly lime-colored, my tool figured an appropriate fallback of:
rgb(133,231,211)

Related

How do I add a triangle at the end of a div with opacity 0.2?

I want it to turn out like this, but unfortunately my triangle goes into the background of the next stage. I spent 3 hours on it. Help please
https://stackblitz.com/edit/angular-3llbmq?file=src/components/sales-funnel/sales-funnel.component.html
Here it is done with polygon, adapt colors yourself
div.container {
display: inline-flex;
align-items: center;
position: relative;
background: black;
width: 100%;
}
div.tangle {
height: 50px;
width: 200px;
clip-path: polygon(0% 20%,
60% 20%,
95% 20%,
100% 50%,
95% 80%,
60% 80%,
0% 80%);
}
div.tangle:nth-child(1) {
background:lightgreen;
transform: translateX(20px);
z-index:3;
}
div.tangle:nth-child(2) {
background:green;
transform: translateX(10px);
}
div.normal {
height: 30px;
width: 200px;
background: white;
}
<div class="container">
<div class="tangle"></div>
<div class="tangle"></div>
<div class="normal"></div>
</div>
This can easily be achieved with the use of ::before and ::after pseudo-elements - with one providing the background of the 'next step' and one providing the triangle with the 'current step' bg color.
Not sure if you neeed a elements in the lis - so I just did straight li's but it would not be hard to change the styling for the use of a elements.
Its best not to try to to use opacity for the step differences - its more accessible to use hex codes directly rather than the one hex code with different opacity values.
Note that the solution of preventing the bleeding color is to space the li's apart with margin and to use the before / after pseudo-elements to fill the gaps - its better to do this than overlap the element over he next step to prevent issues with clicking on areas that are covered by the triangles
ul {
display: flex;
list-style: none;
padding: 0;
border: solid 1px #d4d4d4;
background: lemonChiffon
}
li {
font-size: 16px;
line-height: 20px;
margin-right: 16px;
padding: 4px 32px 4px 8px;
position: relative;
}
.visited {
background: #AFD954;
color: #fff;
}
.visited::before {
content: '';
width: 16px;
height: 28px;
z-index: 5;
position: absolute;
top: 0;
right:-16px;
background: #9BCE29
}
.visited::after {
content: '';
width: 0;
height: 0;
border-top: 14px solid transparent;
border-bottom: 14px solid transparent;
border-left: 14px solid #AFD954;
position: absolute;
right:-14px;
z-index: 9;
top: 0
}
.active {
background: #9BCE29;
color: #fff
}
.active::before {
content: '';
width: 16px;
height: 28px;
z-index: 5;
position: absolute;
top: 0;
right:-16px;
background: lemonChiffon
}
.active::after {
content: '';
width: 0;
height: 0;
border-top: 14px solid transparent;
border-bottom: 14px solid transparent;
border-left: 14px solid #9BCE29 ;
position: absolute;
right:-14px;
z-index: 9;
top: 0
}
.not-visited {
background: lemonChiffon
}
<ul>
<li class="visited">New Deal</li>
<li class="active">Contact</li>
<li class="not-visited">Qualified</li>
</ul>
I had edited your stackbliz example. Please note the HTML and CSS changes.
Don't use opacity to lighten the color. Instead, use SCSS lighten and darken methods.
Please utilize the most of the CSS than the HTML part for the assigning styles. Utilize the classes you have.
NOTE: Please take the benefit of SCSS variables, nesting and pre-defined methods.
Added the reverse z-index to stack the previous element to place over next element.
Below 6 is the total elements
[ngStyle]="{
zIndex: 6 - i
}"
https://stackblitz.com/edit/angular-jhk6qf?file=src/components/sales-funnel/sales-funnel.component.scss

CSS height animation on hover image/icon

I have a problem with my icon when on hover. I want to replace my img src during on hover: heres my code so far:
#aks {
width: 0px;
max-height: 0;
transition: max-height 0.15s ease-out;
overflow: hidden;
background: url("https://img.icons8.com/windows/32/000000/like.png") no-repeat;
padding: 50px;
}
#aks:hover {
background: url("https://img.icons8.com/officexs/32/000000/like.png")
no-repeat;
max-height: 500px;
transition: max-height 0.25s ease-in;
}
<img id="aks" src="https://img.icons8.com/windows/32/000000/like.png" />
What I really want to achieve is when hovered on outline heart icon will replace with heart filled icon but during replacing the outline icon it will show/animate from bottom height 0 to full height so it look like it filled the outline icon. here some example: codepen
any alternatives or solutions other than this is highly appreciated.
thanks in advance!
This isn't particularly easy on a CSS-only heart because the sliding animation would have to be applied to three completely distinct elements (the rotated square, plus the two circles).
For the sake of thoroughness, here is an example using a font that includes a heart. For simplicity, I used Webdings but you should use Font Awesome in actual live code.
The summary is your background is a 2x taller gradient that is 50% white and 50% red, and you slide the background from showing the white half to instead showing the red half upon hover. Two important properties of this will currently only work on webkit browsers: text-stroke, which adds the outline to the text -- and background-clip, which clips the non-text portion of the span's background.
span {
background-size: 100% 200%;
background-image: linear-gradient(to bottom, white 50%, red 50%);
color: transparent;
font-family: webdings;
font-size: 200px;
transition: background-position 2s;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-stroke-width: 5px;
-webkit-text-stroke-color: red;
text-stroke-width: 5px;
text-stroke-color: red;
}
span:hover {
background-position: 0 100%;
}
<span>Y</span>
Well if using css is an option for you then, you can take a look at this:
.heart {
background-color: red;
height: 30px;
width: 30px;
transform: rotate(-45deg);
transition: background-color 1s;
}
.heart::before,
.heart::after {
content: '';
background-color: red;
height: 30px;
width: 30px;
border-radius: 50%;
position: absolute;
transition: background-color 1s;
}
.heart::before {
top: -15px;
}
.heart::after {
left: 15px;
}
.heart:hover,
.heart:hover::before,
.heart:hover::after {
background-color: #F5A9AE;
}
body {
display: flex;
height: 100vh;
}
.heart {
margin: auto;
}
<div class="heart"></div>
You can do it with background animation like below:
.heart {
width: 50px;
height:50px;
padding-top:50px;
background:
url("https://img.icons8.com/officexs/32/000000/like.png") bottom padding-box content-box,
linear-gradient(#fff,#fff) bottom padding-box content-box,
url("https://img.icons8.com/windows/32/000000/like.png");
background-size:100% 100%;
background-repeat:no-repeat;
box-sizing:border-box;
transition:0.5s;
}
.heart:hover {
padding-top:0;
}
<div class="heart"></div>

Transparent text with solid shadow

I'm trying to achieve the effect mentioned in the title:
I used the following code:
.contact-txt h1 {
color: transparent;
font-size: 60px;
line-height: 1em;
text-shadow: 3px 3px #00d44a;
}
But what I get is a green text:
Is there a way to have a transparent text with a solid shadow as in the first picture?
The idea is to have two div stack together, if you only use one with transparent, the shadow is not blocked by text.
Using two could achieve this effect
-webkit-background-clip: text
(currently supported in Chrome, Safari, and Opera, and being implemented in Firefox) is the text value for background-clip. When used along with the proprietary -webkit-text-fill-color: transparent; feature, this allows you to clip background images to the shape of the element's text, making for some nice effects. This is not an official standard, but has been implemented across multiple browsers, as it is popular, and used fairly widely by developers. When used in this context, both of the properties would require a -webkit- vendor prefix, even for Non-Webkit/Chrome-based browsers:
.text-clip {
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
REF: https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_boxes/Advanced_box_effects#-webkit-background-clip_text
div {
position: absolute;
top: 0;
left: 0;
background-image: url(http://www.cameraegg.org/wp-content/uploads/2013/08/AF-S-DX-NIKKOR-18-140mm-f-3.5-5.6G-ED-VR-sample-images-1.jpg);
font-size: 70pt;
font-weight: bold;
line-height: 2em;
padding: .5em;
font-family: Roboto;
}
div.shadow {
color: transparent;
text-shadow: 7px 7px red;
}
div.text {
color: transparent;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
}
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<div class="shadow">DIRECTOR</div>
<div class="text">DIRECTOR</div>
Supported by modern browsers with the exception of Edge, you have mix-blend-mode.
This allows you to set a blend-mode , hard-light, that handles gray as if it was transparent. You then set the color of text to gray, and you got your effect:
.test {
color: gray;
font-size: 100px;
line-height: 1em;
text-shadow: 3px 3px #00d44a;
mix-blend-mode: hard-light;
z-index: 2;
position: absolute;
}
.bkg {
width: 600px;
height: 200px;
top: 0px;
left: 0px;
position: absolute;
background-image: url(http://lorempixel.com/400/200/);
background-size: cover;
z-index: 1;
}
<div class="test">DIRECTOR</div>
<div class="bkg"></div>

Making text background transparent but not text itself

So I am having a problem. I have looked around and looked around but no luck. I would like to make the background of my body transparent but leave the text non transparent. As it is right now I keep making both the same opacity. Here is my code:
#charset "utf-8";
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background-color: #42413C;
margin: 0;
padding: 0;
color: #000;
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl {
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0;
padding-right: 15px;
padding-left: 15px;
opacity:1;
}
a img {
border: none;
}
a:link {
color: #42413C;
text-decoration: underline;
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus {
text-decoration: none;
}
.container {
width: 750px;
margin: 0 auto;
}
.content {
padding:20px;
width:710px;
position:relative;
background:#CCC;
opacity: 0.5;
}
.fltrt {
float: right;
margin-left: 8px;
}
.fltlft {
float: left;
margin-right: 8px;
}
.clearfloat {
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
.header {
top:0%;
width: 750px;
height: 200px;
background-image: url(images/header.png);
background-repeat:no-repeat;
background-position:center;
}
.navbar {
height: 50px;
width: 750px;
position: relative;
z-index: 2;
}
#bg {
position: fixed;
top: 25%;
left: 15%;
z-index: -1;
}
div {
display: block;
}
Here is my website (click the link dont type "tccraft.net" in your url it will take you to a facebook page): http://tccraft.net/index.php
Thank you!
Don't use opacity for this, set the background to an RGBA-value instead to only make the background semi-transparent. In your case it would be like this.
.content {
padding:20px;
width:710px;
position:relative;
background: rgb(204, 204, 204); /* Fallback for older browsers without RGBA-support */
background: rgba(204, 204, 204, 0.5);
}
See http://css-tricks.com/rgba-browser-support/ for more info and samples of rgba-values in css.
For a fully transparent background use:
background: transparent;
Otherwise for a semi-transparent color fill use:
background: rgba(255,255,255,0.5); // or hsla(0, 0%, 100%, 0.5)
where the values are:
background: rgba(red,green,blue,opacity); // or hsla(hue, saturation, lightness, opacity)
You can also use rgba values for gradient backgrounds.
To get transparency on an image background simply reduce the opacity of the image in an image editor of you choice beforehand.
opacity will make both text and background transparent. Use a semi-transparent background-color instead, by using a rgba() value for example. Works on IE8+
Use alpha value instead of using opacity. See code below:
background: rgba(255,255,255,0.2);
If you use RGBA for modern browsers you don't need let older IEs use only the non-transparent version of the given color with RGB.
If you don't stick to CSS-only solutions, give CSS3PIE a try. With this syntax you can see exactly the same result in older IEs that you see in modern browsers:
div {
-pie-background: rgba(223,231,233,0.8);
behavior: url(../PIE.htc);
}
To make the background of your body transparent please try this style, it worked for me, add "ad" at the end of your desired color code
background-color: #42413Cad !important;
I would add Hex color code for transparency
background-color: #42413C+hexcode
https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4
It would be somethin like this:
background-color: #42413C2E
It is equal to that color + 18% alpha
I found a way with z-index.
The watermark class (you can use an example from #19531361) does the job. All input tags are non transparent, but they sit "behind" the watermark. To make them active, use following css modifications (inputs are then "on top").
input {
position:relative;
z-index:10;
}
.watermark {
position: absolute;
opacity: 25%;
z-index:0;
}
box-shadow: inset 1px 2000px rgba(208, 208, 208, 0.54);

z-index not working very well in ipad

I am building a site for a friend (http://pasionesargentas.com/sm/) with the fullscreen gallery with thumbnail flip (http://tympanus.net/codrops/2011/02/09/fullscreen-gallery-with-thumbnail-flip/). I didn't quite like the idea of the flip thing so I simply preferred to disable it and add a menu instead. The menu div css is something like
#top {
position:fixed;
background: transparent;
display: block;
z-index: 99999;
}
It works fine in Chrome, Safari, Explorer and Opera. But for some reason she can't see the menu on her iPad. Since I don't have an ipad I downloaded the Ripple Mission Control and it works fine too so I have no clue what's going on.
Now, the question: Do I have to do css different for tablet browsers (iPad)? Or it is the gallery that's messing up with the menu and covering it?
Had the same problem, wanted to use an overlaying div with a transparent png on top of another div. Found out that z-index will only work on an element whose position property has been explicitly set to absolute, fixed, or relative. Fixed my ipad z-index problem instantly.
.topbar {
display:block;
background: transparent;
height: 60px;
width: 1024px;
display: block;
margin: 0;
padding: 0;
z-index:6;
position:relative;
}
.middlebar {
display:block;
background: transparent;
height: 60px;
width: 1024px;
display: block;
margin: 0;
padding: 0;
z-index:5;
position:relative;
}
.bottom {
display:block;
background: transparent;
height: 758px;
width: 1024px;
display: block;
margin: 0;
padding: 0;
z-index:4;
position:relative;
}
.description {
position: fixed;
top: 5px;
left: 50px;
text-shadow: 1px 1px 1px black;
z-index: 5;
}
#nav:hover {
background: #829FB0;
opacity: 1.0;
filter: alpha(opacity=100);
z-index: 10;
}
#nav {
align: center;
background: #829FB0;
padding: 3px 7px;
display: inline;
opacity: 1.0; //change this later
filter: alpha(opacity=65);
-moz-border-radius: 9px;
border-radius: 9px;
z-index: 10;
}
The problem could be transparent overlying divs, so first replace your code with this code, where the divs/nodes that have to be placed higher are not transparent and then see, also use z-indexes that I have given, you do not need too much high values
When checking for errors in css make sure you make nodes visible and remove their opacity and never give too high values for z-indexes. Try this, if it does not work I will look closely.