This effect uses box-shadow
yes, but also uses transform:scale(1.2);
See this Snipper for an example:
* {
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #3b414d;
overflow: hidden;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.container div {
display: inline-block;
width: 100px;
height: 100px;
background-color: blueviolet;
margin: 0;
padding: 0;
}
.container div:nth-child(2) {
background-color: pink;
transform: scale(1.2);
box-shadow: 0 0 20px rgba(0,0,0,.5)
}
<div class="container">
<div></div>
<div></div>
<div></div>
</div>
If you only want the effect when you do the :hover
just replace the .container div:nth-child(2){}
for .container div:hover{}
* {
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #3b414d;
overflow: hidden;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.container div {
display: inline-block;
width: 100px;
height: 100px;
background-color: blueviolet;
margin: 0;
padding: 0;
transition: all .25s ease-in-out;
position: relative;
z-index: 0;
}
.container div:hover {
background-color: pink;
transform: scale(1.2);
box-shadow: 0 0 20px rgba(0,0,0,.5);
position: relative;
z-index: 2;
cursor: pointer;
}
<div class="container">
<div></div>
<div></div>
<div></div>
</div>
That. But is there any way to make them bigger without a break happening? When I switched to. container div { width: 300px; height: 300px; } a break has occurred
– Maria
@Maria goes like this, take the
display:inline-block;
of.container div
and in class.container
addsdisplay:flex;
that will solve. But everything depends on your project... Where they will stay on the page, if it is responsive etc. This template I made is just an example, it is not the perfect solution for all cases...– hugocsl