As a beginner in programming, I am embarking on the task of creating a basic website inspired by a dribble design.
I am currently struggling to align an image and text side by side within a section, so that they stack on top of each other when the screen is resized. Can someone provide guidance?
Here is how my website currently appears:
https://i.sstatic.net/738qD.jpg
I aim to achieve a layout resembling this dribble design:
https://i.sstatic.net/QCtBc.jpg
This is the HTML code I have:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./new.css">
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,300;0,400;0,700;1,300&display=swap" rel="stylesheet">
<title>Document</title>
</head>
<body>
<header>
<a href="#" class="brand">MYBRAND</a>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Tasks</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">School</a></li>
<li><a href="#">Contact</a></li>
</ul>
</header>
<section class="banner">
<div class="container">
<div class="item">
<h1>Create, <br>and Collect Data</h1>
<div class="text">Change your mind, <br> extract and collect any data for you business.</div>
<button href="#" class="btn-contact btn-style-one">Talk to me</button>
</div>
<div class="item">
<figure class="image">
<img src="1.png" alt="">
</figure>
</div>
</div>
</section>
<script type="text/javascript">
window.addEventListener("scroll", function() {
let header = document.querySelector("header");
header.classList.toggle("sticky", window.scrollY > 390);
})
</script>
</body>
</html>
Below is the CSS code I'm using:
* {
outline: none;
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
body {
min-height: 200vh;
background-color: black;
}
header {
position: fixed;
top: 0;
left: 0;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
transition: 0.6s;
padding: 40px 100px;
z-index: 100000;
}
header .brand {
position: relative;
font-weight: 700;
color: #fff;
text-decoration: none;
font-size: 2em;
text-transform: uppercase;
letter-spacing: 2px;
transition: 0.6s;
}
header.sticky {
padding: 5px 100px;
background-color: #fff;
}
header.sticky .brand,
header.sticky ul li a {
color: #000;
}
header ul {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
header ul li {
position: relative;
list-style: none;
}
header ul li a {
position: relative;
margin: 0 15px;
text-decoration: none;
color: #fff;
letter-spacing: 2px;
font-weight: 500px;
transition: 0.5s;
}
.banner {
position: relative;
width: 100%;
height: 100vh;
background: url(13.png);
background-size: cover;
background-repeat: no-repeat;
}
.container {
display: flex;
width: 100%;
margin: 0 auto;
flex-wrap: wrap;
}
.item {
flex: 1;
margin: 5px;
padding: 0 10px;
text-align: center;
}
btn-contact {
display: inline-block;
}
.btn-style-one {
position: relative;
text-decoration: none;
line-height: 24px;
color: #ffffff;
font-size: 15px;
cursor: pointer;
font-weight: 600;
border-radius: 50px;
border-style: none;
background-color: #ff8048;
text-transform: capitalize;
padding: 16px 32px 16px 32px;
font-family: "Poppins", sans-serif;
box-shadow: 0px 0px 20px rgba(23, 23, 23, 0.15);
background-image: -webkit-gradient(
linear,
left top,
right top,
color-stop(0, #f434a1),
color-stop(100, #ff8442)
);
background-image: -webkit-linear-gradient(left, #f434a1 0%, #ff8442 100%);
background-image: linear-gradient(to right, #f434a1 0%, #ff8442 100%);
}
These are the images I am incorporating:
Background: https://i.sstatic.net/31mId.jpg Dashboard: https://i.sstatic.net/pJIuC.jpg