I was wondering if someone can help me please, I am trying to expand a blur overlay on hover. I want the blur div to be centralised in the middle with a title and then on hover i would like the blur to expand out and overlay the background image. I have included an image of what I mean.
Does anyone know how to achieve this using css3?
any help would be appreciated.
Though a little jerky, this can work for you:
.outerdivs
{
background-color: #ddd;
background-image: url('http://loremflickr.com/400/200');
height: 200px;
position: relative;
width: 400px;
}
.outerdivs > h3
{
color: rgb(255, 102, 2);
height: 30px;
left: 0;
line-height: 30px;
margin-top: -15px;
position: absolute;
text-align: center;
top: 50%;
width: 100%;
z-index: 10;
}
.outerdivs .innerdivs
{
background-color: #fff;
background-image: url('http://loremflickr.com/400/200');
background-position: center center;
-webkit-filter: blur(2px);
filter: blur(2px);
height: 20%;
left: 0;
overflow: hidden;
position: absolute;
top: 50%;
transform: translateY( -50% );
transition: height 0.2s ease;
width: 100%;
z-index: 9;
}
.outerdivs .innerdivs img
{
left: 50%;
opacity: 0.8;
position: absolute;
top: 50%;
transform: translate( -50%, -50% );
}
.outerdivs:hover .innerdivs
{
height: 100%;
}
<div class="outerdivs">
<h3>Title</h3>
<div class="innerdivs">
<img src="http://loremflickr.com/400/200" alt="" />
</div>
</div>
Related
So i have an image i use that is supposed to have a hover function on it. The problem I run into is that the hover area, so where the mouse needs to be to activate the hover function, is way bigger than the image itself. I have linked 2 images below, 1 where the hover is not activated and 1 where it is. On the 2nd image you can clearly see what I mean.
Also below is my HTML and CSS code. I used the following W3 page for this: https://www.w3schools.com/howto/howto_css_image_overlay.asp
Image 1: https://imgur.com/a/jvre00A
Image 2 (you cannot see my mouse, but its all the way over on the right): https://imgur.com/a/OfsQUCB
<div class="containerpic">
<img src="images/duurzaamheid/blauw.png" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
.containerpic {
position: relative;
width: 180px;
}
.image {
display: block;
width: 180px;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 180px;
opacity: 0;
transition: .5s ease;
background-color: green;
}
.container:hover .overlay {
opacity: 0.5;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
Here, is the example. You may see whether image is static or :hover - the area of image remains same.
If you have added some other effects like img:hover {border: 2px solid #bbb;}, or adding some padding or any other effect - then only you'll get mirage that image-area has changed, while in reality it just remains the same.
img:hover {opacity:0.5}
<div><img src="https://picsum.photos/seed/picsum/100/100" /></div>
I modify your code, let see if this will fix it.
<div class="container">
<img src="https://www.w3schools.com/howto/img_avatar.png" class="image">
<div class="overlay">
<div class="text">
Hello World
</div>
</div>
</div>
.container {
position: relative;
width: 180px;
}
.image {
max-width: 100%;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
transition: .5s ease;
background-color: beige;
z-index: 1;
}
.container:hover .overlay {
opacity: 0.5;
}
.text {
color: black;
font-family: 'Arial';
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
width: 100%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 2;
}
This question already has answers here:
CSS background-image-opacity?
(13 answers)
I do not want to inherit the child opacity from the parent in CSS
(18 answers)
Closed 2 years ago.
I have the following code and have added opacity to the solid overlay colour. The problem is that the text is also using the opacity. How do I change it so that the text does not have the opacity and sits on top?
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: #008CBA;
opacity: .5;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
}
.container:hover .overlay {
bottom: 0;
height: 100%;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<div class="container">
<img src="https://cdn.searchenginejournal.com/wp-content/uploads/2019/07/the-essential-guide-to-using-images-legally-online-1520x800.png" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
Thanks John
Instead of opacity, use a RGBA color scheme
RGB: #RRGGBBAA, while A is alpha. you can also use rgba(r,g,b,a)
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: #008CBA99; /* Instead of #008CBA */
overflow: hidden;
width: 100%;
height:0;
transition: .5s ease;
}
.container:hover .overlay {
bottom: 0;
height: 100%;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<div class="container">
<img src="https://cdn.searchenginejournal.com/wp-content/uploads/2019/07/the-essential-guide-to-using-images-legally-online-1520x800.png" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
I have had this problem before and i used ::before,
I used it for images but i assume it also works for background colors
CSS i used;
.style::before{
background-image: url(/images/bg_button.png);
background-repeat: no-repeat;
opacity: 0.15;
width: 100%;
height: 100%;
content: "";
background-size: cover;
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
I am trying to skew both the top and bottom of a div to create a shape that I can then insert a background pattern to however, after a few hours of research I can't really come up with a solid solution. I'm nearly there in the sense that all I need to do is to skew the bottom but am looking for some help or guidance on doing so.
I would like the bottom to mirror the skew of the top. Any suggestions?
#test {
position: relative;
width: 100%;
height: 400px;
}
.bg {
width: 50%;
height: 800px;
-webkit-transition: all 300ms ease-in;
background: black;
border-radius: 80px 0px 0px 80px;
position: absolute;
right: 0;
top: 0;
-ms-transform: skewY(-9deg);
-webkit-transform: skewY(-9deg);
transform: skewY(-9deg);
}
<section id="test">
<div class="bg"></div>
</section>
Example of what I currently have
https://jsfiddle.net/3atsj1e5/
With some rotation and perspective you can do it:
.box {
margin-left: auto;
width: 200px;
height: 450px;
transform-origin: right;
transform: perspective(100px) rotateY(-10deg);
border-radius: 40px 0 0 40px;
overflow: hidden;
}
.box::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url(https://picsum.photos/id/1074/400/800) center/cover;
transform-origin:inherit;
transform: perspective(100px) rotateY(10deg);
}
body {
margin: 0;
background:#eee;
}
<div class="box"></div>
I am trying to make a sort of Venn-Diagram that is going to be used for navigation later.
I have three intersecting ellipsoids created with CSS shapes. Each ellipsoid, as well as their two intersections, will be distinct links later on. Also, when you hover over them they should pop out as per transform: scale(1.3).
My issue is that I'm using ellipsoids which are partially transparent with :after to create the intersections, which creates a problem when hovering over them because the :hover condition gets triggered when hovering anywhere on the partially transparent ellipsoid and not just the :after part. This means that the nonintersecting areas are not hoverable because they are obstructed by the other invisible ellipsoid.
I think the example will make this clearer.
Here is the code:
CSS:
.venn-container{position: relative; left: 0;}
.cat_one{
width: 400px;
height: 200px;
background: red;
border-radius: 200px / 100px;
position: absolute;
float: left;
opacity: 0.5;
}
.cat_two{
width: 400px;
height: 200px;
background: green;
border-radius: 200px / 100px;
position: absolute;
float: left;
left: 240px;
opacity: 0.5;
}
.cat_three{
width: 400px;
height: 200px;
background: blue;
border-radius: 200px / 100px;
position: absolute;
float: left;
left: 480px;
opacity: 0.5;
}
.int1{
background: transparent;
width: 400px;
height: 200px;
border-radius: 200px / 100px;
position: relative;
opacity: 0.5;
overflow: hidden;
float: left;
}
.int1:after{
background: black;
position: absolute;
content: '';
border-radius: 200px / 100px;
width: 400px;
height: 200px;
left: 240px;
}
.int1:hover{
transform: scale(1.3);
left: -35px;
}
.int2{
background: transparent;
width: 400px;
height: 200px;
border-radius: 200px / 100px;
position: relative;
opacity: 0.5;
overflow: hidden;
float: left;
left: 80px;
}
.int2:after{
background: black;
position: absolute;
content: '';
border-radius: 200px / 100px;
width: 400px;
height: 200px;
left: -240px;
}
.int2:hover{
transform: scale(1.3);
left: 115px;
}
HTML:
<div class="venn-container">
<div class="cat_one"></div>
<div class="cat_two"></div>
<div class="cat_three"></div>
<div class="int1"></div>
<div class="int2"></div>
</div>
And here is a fiddle: https://jsfiddle.net/y3Lvmuqg/2/
I would like the :hover to only get triggered in the intersections, and later make cat_one and cat_two hoverable outside the intersections.
I don't know if there is a way I'm doing this is the best and I'm open to suggestions.
Thanks for getting back to me #ge0rg I spent about an hour fiddling with CSS and HTML and came up with this code using just divs with background colors, hover events and border radius's (along with a few z-index and positioning techniques).
Hope you enjoy your reworked venn diagram...
You may have to mess around with the size, and definetly will have to mess with the positioning (however they're all inside a div and so it makes it so that you can just position the div and the rest will happen magically) I added a background color to the div just to show that nothing was transparent, and I also added a always on top function for viewing a section, and I hope you enjoy!
.Venn {
background: linear-gradient(to bottom right, blue, lightblue);
}
.d1:hover, .d2:hover, .d3:hover {
color: #565656;
animation: top 2s steps(2, end) forwards;
-webkit-animation: top 2s steps(2, end) forwards;
box-shadow: 0px 0px 20px white;
}
.d1, .d2, .d3 {
overflow-wrap: break-word;
}
.d1 center, .d3 center {
position: absolute;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
}
.d1 {
padding: 10px;
width: 100px;
height: inherit;
z-index: 1;
position: absolute;
border-radius: 100%;
top: 0px;
}
.d3 {
padding: 10px;
width: 100px;
height: inherit;
z-index: 2;
position: absolute;
border-radius: 100%;
top: 0px;
left: 81px;
}
.d1:hover, .d3:hover {
transform: scale(1.05);
}
.d2 {
border-radius: 100% 0;
height: 90px;
width: 87.5px;
transform: rotate(-45deg) scale(.7);
position: absolute;
top: 15px;
left: 55.35px;
z-index: 3;
border: 1px solid black;
}
.d2b {
transform: rotate(45deg);
padding: 0;
margin: 0;
}
.d2b center {
position: relative;
left: 20px;
}
.d2:hover {
transform: rotate(-45deg);
}
.Venn {
height: 100px;
}
-webkit #keyframes top {
99% {
z-index: previous;
background-image: none;
}
100% {
z-index: 7;
}
}
#keyframes top {
99% {
z-index: previous;
background-image: none;
}
100% {
z-index: 7;
}
}
<div class="Venn" style="position: relative; left: 50px; width: 300px; height: 100px;">
<div class="d1" style=" background-color: grey;">
<center> 1 </center>
</div>
<div class="d2" style=" background-color: #AAAAAA;">
<div class="d2b" style="max-width: inherit;">
<center> 2 </center>
</div>
</div>
<div class="d3" style=" background-color: lightgrey;">
<center> 3 </center>
</div>
</div>
For those of you who would prefer a JSfiddle/ CodePen here you go a Codepen.
I'm a student, and currently busy with creating my own website, but now I've got a question which I can't figure out myself.
My website is about professional cycling and on it I'll have the jerseys of the teams which I want to overlay when going over it with the mouse. I figured this out OK, but now it happens that if I move over it with my mouse, a big square overlays the picture (because it's a square picture with a transparent background) and I want that there is only an overlay over the jersey and not over the "background" of the picture.
I hope you can help me! Need to fix this!
Thank you in advance!
.container {
position: relative;
width: 25%;
height: auto;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #00b0f0;
opacity: 0.8;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
}
.container:hover .overlay {
height: 100%;
}
.text {
white-space: nowrap;
color: white;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
<div class="container">
<a href="AG2R.html">
<img src="https://i.stack.imgur.com/7839q.png" alt="AG2R La Mondiale" title="AG2R La Mondiale" class="image">
</a>
<div class="overlay">
<div class="text">AG2R La Mondiale</div>
</div>
</div>
I found a relevant Stack Overflow thread where the consensus is that this is unachievable with CSS unless you want a pure black image done with filters - which aren't compatible in all browsers and would not have the sliding transition you've implemented.
So I opted to show you how this could look if you created blue overlays yourself in Photoshop as separate PNG images and transitioned with them. I created the PNG by making a layer filled with #00b0f0, set it to 80% opacity and used it as a clipping mask - essentially what your .overlay was trying to do. Here's a demo:
.container {
position: relative;
width: 25%;
height: auto;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
opacity: 0.8;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
}
.overlay .image {
position: absolute;
bottom: 0;
}
.container:hover .overlay {
height: 100%;
}
.text {
white-space: nowrap;
color: white;
text-shadow: #000 0 1px 1px;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
<div class="container">
<a href="AG2R.html">
<img src="https://i.stack.imgur.com/7839q.png" alt="AG2R La Mondiale" title="AG2R La Mondiale" class="image">
</a>
<div class="overlay">
<img src="https://i.stack.imgur.com/DwIGH.png" alt="overlay" class="image" />
<div class="text">AG2R La Mondiale</div>
</div>
</div>