I have a mini-gallery of images which I want to use to toggle content depending on the image clicked. When hovering on the image it scales up slightly. My problem is that when scaling I want to hide the overflow off the page but still show the overflow in the y-direction. I have tried overflow-x: hidden, overflow-y: visible but the y-overflow only appears at the bottom and scrollbars appear.
#images {
height: 70vh;
width: 100%;
display: flex;
flex-wrap: wrap;
overflow-x: hidden;
overflow-y: visible;
}
#images .image {
width: 50%;
height: 35vh;
transition: 0.5s;
cursor: pointer;
z-index: 1;
}
#images .image:hover {
transform: scale(1.1);
z-index: 10;
}
#images .image img {
width: 100%;
height: 100%;
object-fit: cover;
}
<div id="images">
<div class="image">
<img src="image.jpg">
</div>
<div class="image">
<img src="image.jpg">
</div>
<div class="image">
<img src="image.jpg">
</div>
<div class="image">
<img src="image.jpg">
</div>
</div>
Is there a way to make these act as it would with no overflow stated without a scrollbar appearing in the x direction?
You need to add scaling property to image instead of outer div.
#images {
height: 70vh;
width: 100%;
display: flex;
flex-wrap: wrap;
overflow-x: hidden;
overflow-y: visible;
}
#images .image {
width: 49%;
height: 35vh;
transition: 0.5s;
cursor: pointer;
z-index: 1;
overflow: hidden;
position: relative;
border:1px solid #000;
}
#images .image:hover img {
transform: scale(1.1);
z-index: 10;
position: absolute;
left: 0;
transition: .2s;
}
#images .image img {
width: 100%;
height: 100%;
object-fit: cover;
}
<div id="images">
<div class="image">
<img src="https://dummyimage.com/600x400/ffffff/000000">
</div>
<div class="image">
<img src="https://dummyimage.com/600x400/ffffff/000000">
</div>
<div class="image">
<img src="https://dummyimage.com/600x400/ffffff/000000">
</div>
<div class="image">
<img src="https://dummyimage.com/600x400/ffffff/000000">
</div>
</div>
Remove overflow css from the images and add it to the body:
body {
width: 100%;
overflow: hidden;
}
Related
How do I make my image gets centered in the .s-circles-1 <div>...
Html
.s-circles-1 {
display: inline-block;
opacity: 0.1;
margin-left: 315px;
margin-top: 155px;
background-color: #fff;
width: 164px;
height: 164px;
border-radius: 100%;
position: relative;
}
.s-img-1 {
opacity: 0.9;
display: inline-block;
position: absolute;
color: #E37218;
margin-right: 70vw;
width: 120px;
height: 120px;
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="s-circles-1">
<img src="/Shapes/code (1).svg" alt="" class="s-img-1">
</div>
</div>
I am trying to make my image get inserted in the circle.
Thanks in advance.
With background-image :
div.circle {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 100%;
width: 164px;
aspect-ratio : 1 / 1;
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="circle" style="background-image: url(https://thispersondoesnotexist.com/image)"></div>
</div>
With your code, you need to change your css with this (if you don't want to use background-image) :
s-circles-1 class : set overflow:hidden;
s-img-1 class : set
width:100%; and height:100%;
.s-circles-1 {
display: inline-block;
opacity: 0.5;
width: 164px;
aspect-ratio:1 / 1; /* Keep the same width */
border-radius: 100%;
overflow: hidden;
}
.s-circles-1 img {
opacity: 0.9;
width: 100%;
height: 100%;
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="s-circles-1">
<img src="https://thispersondoesnotexist.com/image" alt="">
</div>
</div>
With your code, but if your image is not a square :
div.circle {
display: flex;
justify-content: center;
align-items: center;
border-radius: 100%;
width: 164px;
aspect-ratio : 1 / 1;
overflow: hidden;
}
div.circle img {
/*if width > height*/
height: 164px;
/*if height > width*/
/*width: 164px;*/
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="circle">
<img src="https://dummyimage.com/1200x500/000/fff" alt="" class="circle">
</div>
</div>
My HTML is:
<div class="event-presentation-featured">
<div class="event-presentation-featued__image-container">
<a href="...">
<img class="event-presentation-featued__image" src="...">
</a>
</div>
<div class="event-presentation-featured__content">
...
</div>
<div class="event-presentation-featured__actions">
...
</div>
</div>
I want the image to NOT expand the height of the containing div. Presently it looks like:
The relevant classes are:
.event-presentation-featured {
align-items: stretch;
background-color: var(--color-white);
display: flex;
width: 100%;
}
.event-presentation-featued__image-container {
flex-shrink: 1;
max-width: 457px;
position: relative;
}
.event-presentation-featued__image {
top: 0;
left: 0;
display: block;
object-fit: cover;
object-position: center;
width: 100%;
height: 100%;
}
A horizontal scrolling container is what I'm creating. Everything is operating smoothly. The problem, though, is that I want to put a picture on top of each card. But rather than being on top of the wrapper, the picture goes within. What could be the best solution?
.scrolling-wrapper {
-webkit-overflow-scrolling: touch;
height: 300px;
width: 100%;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
padding-inline: 40px;
position: relative;
}
.scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.card {
display: inline-block;
height: 100%;
width: 300px;
background-color: red;
border-radius: 20px;
position: relative;
margin-right: 10px;
}
.our-member-owner-card-image {
position: absolute;
top: -70px;
z-index: 9999;
}
<div class="scrolling-wrapper">
<div class="card">
<div class="our-member-owner-card-image">
<img width="220px" src="https://images.unsplash.com/photo-1668767483967-cc2325edafbf?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" />
</div>
</div>
<div class="card">
<div class="our-member-owner-card-image">
<img width="220px" src="https://images.unsplash.com/photo-1668767483967-cc2325edafbf?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" />
</div>
</div>
</div>
When I am applying hover on the card container it is not working or it is not flipping but I when I remove the hover it flips to the back side, I have tried everything that I know but still no progress on that.
`
import React from 'react'
import './Summary.css'
function Summary() {
return (
<div className='summary'>
<img className="body__image" src={require("./Images/background3Color.jpg")}></img>
<div className='box__container'>
<div className='boxes'>
<div className='box__inner'>
<div className='box__front'>
<img className='boxes__pics' src={require('./Images/AboutMe.jpg')}></img>
</div>
<div className='box__back'>
<div className='headline'></div>
<div className='education'>
<h2>Bachelor Of Technology in Computer Science and Tech.</h2>
</div>
<div className='work-ex'>
<p>Worked as an Application Dvelopment Associate in Accenture for 1 year</p>
</div>
</div>
</div>
</div>
<div className='boxes'>
<div className='box__inner'>
<div className='box__front'>
<img className='boxes__pics' src={require('./Images/Contacts.jpg')}></img>
</div>
<div className='box__back'>
<div className='headline'></div>
<div className='education'>
<h2>Bachelor Of Technology in Computer Science and Tech.</h2>
</div>
<div className='work-ex'>
<p>Worked as an Application Dvelopment Associate in Accenture for 1 year</p>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default Summary
`
I was expecting the flip will work but to no avail.
I have tried to add hover to both box__inner and boxes container but still it would not flip.
Here is what I tried:
`
.summary{
position: relative;
height: 100vh;
z-index: -1;
}
.body__image{
height: 100vh;
}
.box__container{
position: absolute;
/* background-color: aqua; */
top: 0px;
width: 100%;
height: 100%;
/* opacity: 0.4; */
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
align-items: center;
}
.boxes{
height: 320px;
width: 300px;
margin: 0px 10px 0px 10px;
position: relative;
background-color: rgba(107,186,167,0.7);
perspective: 1000px;
overflow: hidden;
}
.box__inner{
position: absolute;
width: 100%;
height: 100%;
text-align: center;
transition: all 0.8s ease;
transform-style: preserve-3d;
}
.boxes__pics{
height: 100%;
width: 100%;
opacity: 0.7;
}
.box__inner:hover{
cursor: pointer;
transform: rotateY(180deg);
}
.box__front, .box__back{
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.box__front{
}
.box__back{
transform: rotateY(180deg);
}
`
The z-index was causing the main problem after removing it from the parent div the hover effect worked fine.
Consider the following HTML/CSS:
.container {
width: 100%;
height: 200px;
overflow: hidden;
}
.container img {
max-width: 100%;
height: auto;
}
<div class="container">
<img src="http://www.wallpapereast.com/static/images/HD-Wallpapers1_Q75eDHE.jpeg" alt="img" />
</div>
JSFiddle
Is there any way I can vertically center the image in it's container?
.container {
width: 100%;
height: 200px;
overflow: hidden;
object-fit: cover;
}
.container img {
max-width: 100%;
height: auto;
position: relative;
top: 50%;
left: 0;
transform: translate(0, -50%);
}
<div class="container">
<img src="http://www.wallpapereast.com/static/images/HD-Wallpapers1_Q75eDHE.jpeg" alt="img" />
</div>
Your image is bigger than your container... Is it normal ?
I suggest you to use a background image in this case... (with background-position: center and background-size:cover)
Change css
CSS
div.horizontal {
display: flex;
justify-content: center;
}
div.vertical {
display: flex;
flex-direction: column;
justify-content: center;
}
.container {
width: 100%;
height: 200px;
overflow: hidden;
object-fit: cover;
}
.container img {
max-width: 100%;
height: auto;
}
HTML
<div class="horizontal container div1">
<div class="vertical">
<img src="http://www.wallpapereast.com/static/images/HD-Wallpapers1_Q75eDHE.jpeg" alt="img" />
</div>
</div>
Demo Link http://jsfiddle.net/LWrSD/430/