DIV exiting the screen

Asked

Viewed 390 times

3

I’ve seen several times a div kind of coming off the screen, and as I won’t be able to explain it properly, I’ll show you a picture of an example:

inserir a descrição da imagem aqui inserir a descrição da imagem aqui

I figured it would be box-shadow, but I couldn’t do it. I don’t want to do the same design of the boy, until I will not "steal" his work, but I wanted to know how it does to look like this, leaving the screen.

Link: https://dribbble.com/shots/4150795-Conceptual-Dashboard-UI-Analytics

1 answer

2


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

  • 1

    @Maria goes like this, take the display:inline-block; of .container div and in class .container adds display: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...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.