I’m working my way through an online course and run into a problem. We are supposed to create a site that looks like this:
Goal Site
Currently, my website looks like this:
My Website
Here is the HTML and CSS code I am trying to amend:
<body>
<div class="main">
<img class="logo" src="./assets/images/logo.png" alt="logo">
<h1>We are a <span style="color: darkblue;">Creative</span> Design Agency</h1>
<div class="left card"><img class="tile-image-left tile-image" src="./assets/images/beautiful.jpg" alt="hand and flower in water">
<h2 class="card-title">Beauty</h2>
<p class="card-text">We strive to create the most beautiful websites for all your needs. Working closely with you
to
design and
develop an amazing website for your business.</p>
</div>
<div class="right card"><img class="tile-image-right tile-image" src="./assets/images/construction.jpg" alt="metal structure">
<h2 class="card-title-right">Construction</h2>
<p class="card-text-right">Built by our team of professional developers, we ensure the most rigourous and modern websites. Built from
scratch using HTML and CSS. Only the best for you.</p>
</div>
</div>
<footer>
<p>Create. Develop. Design.</p>
</footer>
</body>
body {
font-family: "Poppins", sans-serif;
margin: 50px 50px 0 50px;
background-color: #faf9f6;
display: flex;
flex-direction: column;
min-height: 95vh;
}
.main {
flex: 1;
}
h1 {
font-size: 5rem;
}
footer {
text-align: right;
color: midnightblue;
}
.tile-image{
height: 200px;
}
.tile-image-left{
float: left;
clear: both;
}
I’ve tried to set the div’s, images, and text to ‘inline-block’ but that hasn’t worked.
I’ve also tried to float the text by the images, but found that the 2nd image always seems to move out of place, as seen by the image it is directly below my first image, but I need them to be side to side.
I’m not sure how to tackle this so I’d appreciate the help if you can spare the time.
Regards,
Proton
2
Answers
Wrap your
left
andright
cards inside a parent div (.cards
in the below example). Then, wrap your text content inside a parent (aside
in the example).Then it’s just a case of setting both to
flex
display.You’ll have to add margins/paddings to get it exactly like the design.
I have tried this in my project which I have implemented but I am presenting small portion of it.
It has HTML and CSS both and is presented as a demo.