how to change the opacity of background image? [closed] - html

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I made a slider with pure css and I want to set the background opacity of each background-image (so, that I can give it a nice fade animation). I know that I could use css generated content to add image using opacity: 1; property but I have a lot of css code so is there any easy way to get around this??
without any generated content or psuedo-elements??
/************ SLIDER ************/
/*this contains the slides which are inside a wrap*/
#slide-Panel{
width: 100%;
height: 40%;
overflow: hidden;
}
/*this contins the slides*/
.wrap{
position: relative;
width: 100%;
height: 100%;
background: #000;
text-align: center;
overflow: hidden;
}
.slide{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 100%;
z-index: 10;
background: #000;
background-repeat: no-repeat;
background-position:50% 50%;
background-size: cover;
padding: 2em 2em;
color: white;
font-size: 1em;
}
.slide a {
background: #0FCABF;
padding: .6rem 1.6rem;
color: white;
font-weight: 700;
margin: 1rem;
}
.wrap input[type="radio"]{
position: absolute;
z-index: 200;
bottom: 10%;
left: auto;
right: auto;
}
.wrap input[type="radio"]:nth-of-type(1){
margin-left: -1.2rem;
}
#slider-2-trigger{
margin-left: .4rem;
}
.slide-two{
background-image: url('https://snap-photos.s3.amazonaws.com/img-thumbs/960w/35VYJ0NK0V.jpg');/*change the opacity of these images*/
}
.slide-one{
background-image: url('https://images.unsplash.com/photo-1432821596592-e2c18b78144f?crop=entropy&fit=crop&fm=jpg&h=750&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=1175');/*change the opacity of these images*/
}
[id^="slider"]:checked + section {
z-index: 100;
left: 0;
}
.slide :not(img){
display: none;
}
.slide img{
opacity: .6;
width: 220px;
height: 148px;
margin: 2em auto;
}

There is no direct way to change the opacity of a background image.
But here's a workaround, please try this.
Here's the code you should use:
div::after {
content: "";
// Add your background image here
background: url("https://upload.wikimedia.org/wikipedia/commons/2/29/Example_image_not_be_used_in_article_namespace.jpg");
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
And the JSFiddle to it.

Related

How could I create a transition effect similar to the "start voting" button on this website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I would like to create a transition effect on hover that is similar to the large "start voting" button on this website but, while I am familiar with css transition effects, I dont know how to create that one in particular. Thank you for taking the time to read this.
You can use a background-size transition:
a {
position: relative;
display: inline-block;
padding: 12px 80px;
border: 2px solid #BDAA67;
color: white;
font-size: 30px;
text-decoration: none;
background-color: black;
background-image: linear-gradient(#BDAA67, #BDAA67);
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: 0% 0%;
transition: background-size .3s, color .3s;
}
a:hover {
background-size: 100% 100%;
color: #000;
}
<a href="#" class="button">
CLICK ME!
</a>
{content: "";
background-color: #bdaa67;
height: 0%;
width: 50%;
position: absolute;
left: 25%;
transition: all .15s ease-in-out;
top: 48%;
z-index: -1;}
Try this
Add the following lines of code to your HTML,
<button class="custom-btn">Start now</button>
Add the following lines of code to your custom.css. This will give the exact style on hover for the button. You can minimise the code if you are willing to use bootstrap. Here we have custom styled the button from scratch.
.custom-btn {
font-size: 25px;
padding: 32px 105px;
text-shadow: none;
border: 2px solid #000;
background: #000;
color: #fff;
font-weight: bold;
text-transform: uppercase;
position: relative;
z-index: 1;
transition: all .33s ease-in-out;
}
.custom-btn:hover {
border: 2px solid #bdaa67;
color: #000;
}
.custom-btn::before {
content: "";
background-color: #bdaa67;
height: 0%;
width: 50%;
position: absolute;
left: 25%;
transition: all .15s ease-in-out;
top: 48%;
z-index: -1;
}
.custom-btn:hover::before {
height: 100%;
width: 100%;
left: 0;
top: 0;
}
<body>
<button> START VOTING </button>
</body>
body {
margin: 0;
padding: 0;
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background: red;
}
button {
position: absolute;
padding: 40px 120px;
font-weight: bold;
border: 0;
color: #fff;
font-size: 2em;
text-transform: uppercase;
background: #000;
z-index: 1;
}
button::before {
content:"";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #bdaa67;
transform: scale(0);
transition: 0.3s;
z-index: -1;
}
button:hover:before {
transform: scale(1);
}
button:hover {
border: 3px solid #bdaa67;
color: #000;
}

Responsive DIV with with video inside

I have the following html and CSS that I need to make responsive.
It starts with a lightweight YouTube video embedding (less YouTube code to download) found from labnol.org. I then wrapped the youtube-player div with two other divs to horizontally center the video.
I've tried a few solutions I've seen here in SO, but have not been able to make this work. I would like to be able to set the max width in any display, but not have it go off the edge of the screen when viewed on mobile devices.
I would greatly appreciate any help. Thank you.
HTML:
<div id="videoParent" class="videoParent">
<div id="videoDiv" class="videoDiv">
<div class="youtube-player" data-id="gmX8VFlrv38"></div>
</div>
</div>
with the following CSS.
<style>
<style>
.videoDiv {
max-width:560px;
display:inline-block;
width:90%;
}
.videoParent {
text-align:center;
}
.youtube-player {
position: relative;
padding-bottom: 56.23%;
/* Use 75% for 4:3 videos */
height: 0;
/*width:400px; */
overflow: hidden;
max-width: 100%;
background: #000;
margin: 5px;
}
.youtube-player iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
background: transparent;
}
.youtube-player img {
bottom: 0;
display: block;
left: 0;
margin: auto;
max-width: 100%;
width: 100%;
position: absolute;
right: 0;
top: 0;
border: none;
height: auto;
cursor: pointer;
-webkit-transition: .4s all;
-moz-transition: .4s all;
transition: .4s all;
}
.youtube-player img:hover {
-webkit-filter: brightness(75%);
}
.youtube-player .play {
height: 72px;
width: 72px;
left: 50%;
top: 50%;
margin-left: -36px;
margin-top: -36px;
position: absolute;
background: url("//i.imgur.com/TxzC70f.png") no-repeat;
cursor: pointer;
}</style>
I simplified my CSS to the following at it appears to be doing what I need it to.
.videoParent {
text-align:center;
}
.videoDiv {
max-width:560px;
display:inline-block;
width:60%;
}

Adding tooltip hover to an image with css

I want to create a tooltip (using css) that appears once the user moves the mouse over an element. I made it work for text, but I have problems making it work for an image.
.container {
position: relative;
width: 15%;
}
.image {
position: relative;
display: inline-block;
width: 100%;
height: auto;
}
.image .tooltiptext2 {
visibility: hidden;
width: 150%;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -8px;
left: 110%;
font-size: 150%;
font-family: Arial;
/* Fade in tooltip - takes 1 second to go from 0% to 100% opac: */
opacity: 0;
transition: opacity 1s;
}
.image .tooltiptext2::after {
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
.image:hover .tooltiptext2 {
visibility: visible;
opacity: 1;
}
You can see what I did in this link:
https://jsfiddle.net/Ruloco/q3e4psh3/
I'll apreciate any help you could give me. Thanks in advance!!
.tooltiptext2 is not a child of .image. Using .image + .tooltiptext2 instead of .image .tooltiptext2 makes the tooltip work.
https://jsfiddle.net/8Lmz2oLj/
The tooltip isn't a child of the image. You need to amend your styles so that the image container is the thing you're listening for a hover on.
.container:hover .tooltiptext2 {
visibility: visible;
opacity: 1;
}
https://jsfiddle.net/q3e4psh3/1/

css3 gradient with line on top [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
so im trying to make an infographic to a website im making and i want to make a gradient that has a line on top like in this image: https://ibb.co/e8xmCk where there is a gradient and a line on top of it with a diffrent color and that to be a background of a specific place. thanks a lot!
I was really unable to understand your question actually, but
nevertheless I have made a solution that you want like..
.container {width: 100%; height: 200px; background: linear-gradient(to right, rgba(0,0,0,1), rgba(0,0,0,0)); position: relative; box-sizing: border-box; z-index: 1;}
.container:before {display: block; content: ""; height: 10%; width: 100%; background: red; position: absolute; top: 0px; left: 0px; z-index: -1;}
h1 {font-family: Arial; font-size: 49px; font-weight: bold; color: #fff; text-align: center; margin: 0px;}
<div class="container">
<h1>This is text here..!</h1>
</div>
And another is here...
.container {width: 100%; height: 200px; background: linear-gradient(to right, rgba(0,0,0,1), rgba(0,0,0,0)); position: relative; box-sizing: border-box; z-index: 1; overflow-y: hidden;}
.container:before {display: block; content: ""; height: 10%; width: 100%; background: red; position: absolute; top: 0px; left: 0px; z-index: -1;}
.side-panel {height: 100%; width: 30%; position: absolute; top: 0px; left: -10%; background: #2493a4; z-index: -2; transform: skew(20deg);}
h1 {font-family: Arial; font-size: 49px; font-weight: bold; color: #fff; text-align: center; margin: 0px;}
<div class="container">
<div class="side-panel"></div>
<h1>This is text here..!</h1>
</div>

CSS Brightness on opacity [duplicate]

This question already has answers here:
I do not want to inherit the child opacity from the parent in CSS
(18 answers)
Closed 7 years ago.
So i have a div and in that div i have a button and a text box. The div i have set with opacity of 0.5. Okay perfect, however i do not want all of the content in the div to be transparent. How can i make the textbox and button full brightness?
.bodybox {
position:absolute;
background-color: white;
top: 160px;
width: 960px;
height: 450px;
z-index: 13;
margin-left: 24.736842105263158%;
margin-right: 24.736842105263158%;
opacity: 0.1;}
This is what i have so far so you can see what i mean.
In such cases rgba helped me. Substitute background value.
bodybox {
position:absolute;
background: rgba(255, 255, 255, 0.5);
top: 160px;
width: 960px;
height: 450px;
z-index: 13;
margin-left: 24.736842105263158%;
margin-right: 24.736842105263158%;
opacity: 0.1;
}
You can use the :after attribute if you have an image
.bodybox {
position: relative;
}
.bodybox:after {
content : "";
display: block;
position: absolute;
top: 0;
left: 0;
background-image: url(/wp-content/uploads/2010/11/tandem.jpg);
width: 100%;
height: 100%;
opacity : 0.2;
z-index: -1;
}
Or,if you only have a background-color, you can use rgba:
.bodybox {
position:absolute;
background-color: rgba(255,255,255, 0.1)
top: 160px;
width: 960px;
height: 450px;
z-index: 13;
margin-left: 24.736842105263158%;
margin-right: 24.736842105263158%;
}