Answer the question
In order to leave comments, you need to log in
When imposing one object on another, the picture is cut off, what's the problem?
Hello! When using position: absolute on an image and position: relative on a button, the height of the image becomes equal to the height of the button. How can this problem be solved?
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<!-- css -->
<link rel="stylesheet" href="css/style.css">
<!-- fonts -->
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,[email protected],300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap" rel="stylesheet">
<title>Maket</title>
</head>
<body>
<!-- navbar -->
<header>
<div class="container-fluid">
<div class="row">
<div class="col-md-10 offset-md-1">
<nav class="navbar navbar-expand-md navbar-light p-4">
<a class="navbar-brand" href="#">
<img src="img/logo.png" alt="logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="#">Home</a></li>
<li class="nav-item"><a class="nav-link" href="#">How it works</a></li>
<li class="nav-item"><a class="nav-link" href="#">Discover a project</a></li>
<li class="nav-item"><a class="nav-link" href="#">Blog</a></li>
<li class="nav-item"><a class="nav-link" href="#">Find our more</a></li>
<button type="button" class="btn">Login</button>
</ul>
</div>
</nav>
</div>
</div>
</div>
</header>
<!-- header -->
<div class="slider">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/header-slider-1.png" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="img/header-slider-1.png" class="d-block w-100" alt="...">
</div>
<button type="button" class="btn">Login</button>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
</body>
</html>
<code lang="css">
body{
margin: 0;
}
header .navbar{
text-transform: uppercase;
font-family: 'Open Sans', sans-serif;
font-weight: 600;
}
header .navbar .nav-item{
margin-right: 20px;
padding-top: 5px;
}
header .navbar .btn{
margin-left: 90px;
background-color: #bcda5c;
padding: 10px 30px;
border-radius: 30px;
color: #fff;
font-weight: 600;
text-transform: uppercase;
}
.slider .carousel-item img{
position: absolute;
}
.slider .btn{
position: relative;
}
</code>
Answer the question
In order to leave comments, you need to log in
I don't know much about CSS, but it seems to me that you need to replace the space ' ' with the combinator '>', i.e. .slider > .carousel-item > img and .slider > .btn
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question