For example in the following I have implemented in row wise flex-direction
of the container
, as you can see the content of even the rightmost div don’t overflow out of the page to right.
Similarly we can do for column-wise as well if we set flex direction of container to column. But I need both together where container is a grid layout with arbitrary number of rows and columns where the content of any grid neither overflows to right nor bottom of the grid.
.container{
display: flex;
flex-direction: row;
justify-content: center;
}
.box{
width: 200px;
height: 250px;
background: orange;
margin: 0px 10px;
overflow: hidden;
transition: all 1500ms ease-in;
//transition-property: height, width, background, box-shadow;
}
.box:hover{
width: 120%;
height: 120%;
background: #ff800a;
z-index: 2;
box-shadow: 2px 2px 2px #000;
}
<div class="container">
<div class="box">Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or Ishan, it seems like you're interested in information related to "anyshare." it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or the latest updates. However, if you have specific questions or topics related to if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.</div>
<div class="box"></div>
<div class="box">t have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or my best to Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or Ishan, it seems like you're interested in information related to "anyshare." it seems like you're interested in information related to "anyshare." it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific que</div>
</div>
<hr>
<div class="container">
<div class="box"></div>
<div class="box"></div>
<div class="box">Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or Ishan, it seems like you're interested in information related to "anyshare." it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or Ishan, it seems like you're interested in information related to "anyshare." let me know, and I'll do my best to assist you.Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, information related to "anyshare."Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, information related to "anyshare." Unfortunately, Ishan, it seems like you're interested in information related to "anyshare." Unfortunately, I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to if you have specific questions or I don't have real-time internet access to provide the latest updates. However, if you have specific questions or topics related to "anyshare" that you'd like insights on, feel free to let me know, and I'll do my best to assist you.</div>
</div>
I have tried to stack two container
divs to create two rows but as you can see, the second row is overflowing the bottom of the page. Ideally it should push 1st row up to remain within view.
To summarise, My requirement is the currently zoomed div should strictly remain within the view wherever in the grid it may be located.
PS: By grid-layout I mean css properties grid-auto-rows
or grid-auto-columns
.
2
Answers
Found what I was looking for
You can do this by translating the hovered box to the center of the screen and zoom it. This can be done using
position: fixed;
andtransform: translate
properties. I did it using an animation keyframe:Note: Using css to move the
box
to the center like above, may remove thehover
activation because the mouse stays stationary while thebox
moves away. This causes (unwanted) jitter/glitches.To Fix this, I have used javascript to toggle between style classes:
The boolean
isCurrentlyAnimating
is to prevent the box from going back to its normal state while it is being slowly translated to the center andisAnyBoxActive
(this prevents the glitch).The boolean
isAnyBoxActive
, prevents other boxes from being madeactive
while one is alreadyactive