Увеличение элемента в границах его самого
Подскажите, пожалуйста, как сделать так, чтобы при наведении на элемент img он увеличивался в своих границах и не залазил на соседние элементы?
С левой стороной элемента я разобрался, а вот с правой нет, при увеличении залазит на белый элемент справа.
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- displays site properly based on user's device -->
<link
rel="icon"
type="image/png"
sizes="32x32"
href="./images/favicon-32x32.png"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css" />
<script
type="module"
src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"
></script>
<script
nomodule
src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"
></script>
<title>Frontend Mentor | Product preview card component</title>
</head>
<body>
<main>
<div class="container">
<div class="product-container">
<div class="content">
<img
class="image"
src="images/image-product-desktop.jpg"
alt="Perfume Image"
/>
<div class="text-block">
<div class="main-text">
<div class="name">
<p>Perfume</p>
<h1>Gabrielle Essence Eau De Parfum</h1>
</div>
</div>
<div class="description">
<p>
A floral, solar and voluptuous interpretation composed by
Olivier Polge, Perfumer-Creator for the House of CHANEL.
</p>
</div>
<div class="prices">
<h2 class="main-price">$149.99</h2>
<p class="second-price">$169.99</p>
</div>
<button class="btn">
<ion-icon class="icon" name="cart-outline"></ion-icon> Add to
Cart
</button>
</div>
</div>
</div>
</div>
<div class="attribution">
Challenge by
<a href="https://www.frontendmentor.io?ref=challenge" target="_blank"
>Frontend Mentor</a
>. Coded by <a href="#">Your Name Here</a>.
</div>
</main>
</body>
</html>
@import url("https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;700&display=swap");
:root {
--dark-cyan: hsl(158, 36%, 37%);
--cream: hsl(30, 38%, 92%);
/* Neutral */
--very-dark-blue: hsl(212, 21%, 14%);
--dark-grayish-blue: hsl(228, 12%, 48%);
--white: hsl(0, 0%, 100%);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Montserrat", "Fraunces", serif;
background-color: var(--cream);
}
.container {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.product-container {
background-color: var(--white);
border-radius: 25px;
width: 650px;
box-shadow: 0px 0px 20px 20px rgba(215, 210, 210, 0.2);
overflow: hidden;
}
.content {
display: flex;
flex-direction: row;
}
.content img {
width: 50%;
transition: all 0.7s;
border-radius: 25px 0px 0px 25px;
}
.content img:hover {
transform: scale(1.1);
}
.image {
height: 500px;
width: 325px;
}
.text-block {
display: flex;
flex-direction: column;
padding: 2rem 2rem 2rem 2rem;
width: 50%;
}
.name p {
font-size: 10px;
font-weight: 400;
margin-bottom: 20px;
text-transform: uppercase;
letter-spacing: 5px;
color: var(--dark-grayish-blue);
}
.name h1 {
font-family: "Fraunces";
line-height: 1em;
font-weight: 700;
max-width: 200px;
margin-bottom: 20px;
}
.description p {
font-size: 15px;
font-family: "Montserrat", sans-serif;
line-height: 1.8em;
font-weight: 500;
color: var(--dark-grayish-blue);
max-width: 250px;
margin-bottom: 30px;
}
.prices {
display: flex;
justify-content: stretch;
column-gap: 20px;
align-items: center;
margin-bottom: 29px;
}
.prices .main-price {
font-size: 40px;
color: var(--dark-cyan);
font-family: "Fraunces", serif;
font-weight: 700;
}
.prices .second-price {
font-size: 15px;
text-decoration: line-through;
color: var(--dark-grayish-blue);
}
.btn {
display: flex;
justify-content: center;
align-items: center;
column-gap: 10px;
padding: 15px;
border-radius: 8px;
border: none;
background-color: var(--dark-cyan);
color: var(--white);
font-size: 15px;
font-family: "Montserrat", sans-serif;
font-weight: 700;
transition: all 0.5s;
}
.icon {
font-weight: 500;
height: 20px;
width: 20px;
color: var(--white);
}
.btn:hover {
background-color: var(--white);
color: var(--dark-cyan);
cursor: pointer;
box-shadow: 2px 2px 0 var(--dark-cyan) inset,
-2px -2px 0 var(--dark-cyan) inset;
}
.btn:hover .icon {
color: var(--dark-cyan);
}