screenshotHello everyone I am a new code writer and I am confused about aligning two paragraphs right next to each other.
As you see I am trying to align the price to the right side of the product name and I want it to margin itself automatically. But it insists stay under the product name.
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: sans-serif;
}
.header {
background-color: darkcyan;
text-align: center;
padding: 16px;
width: 100%;
border-bottom: 4px solid black;
}
.container {
background-color: blue;
height: 100%;
width: 100%;
margin: 0;
padding-top: 80px;
}
.first-prod {
background-color: aquamarine;
width: 250px;
height: 250px;
align-items: center;
margin: auto;
}
.second-prod {
background-color: aliceblue;
width: 250px;
height: 250px;
align-items: center;
margin: auto;
margin-top: 80px;
}
.third-product {
background-color: aliceblue;
width: 250px;
height: 250px;
align-items: center;
margin: auto;
margin-top: 80px;
}
.images {
width: 150px;
height: 150px;
object-fit: cover;
border-radius: 10px;
margin-top: 12px;
}
.first-content {
align-items: center;
text-align: center;
}
.fcp1 {
color: brown;
width: 74px;
margin: auto;
background-color: aliceblue;
border-right: 2px solid black;
margin-top: 20px;
font-size: 18px;
}
.fcp2 {
color: brown;
width: 74px;
margin-left: 160px;
background-color: aliceblue;
margin-top: 13px;
font-size: 18px;
}
<header class="header">
<h1>Babark Commerce</h1>
<p>Everything you looking for...</p>
</header>
<div class="container">
<div class="first-line">
<div class="first-prod">
<div class="first-content">
<img src="watch.jpg" alt="watch" class="images">
<p class="fcp1">Elegant CASSIO EA0732</p>
<p class="fcp2">58 £</p>
</div>
</div>
<div class="second-prod">
</div>
<div class="third-product">
</div>
</div>
</div>
I tried to align items right next to each other. But elements ordered as up-down.
In order to align two Paragraph together in a row you can do the following.
<span class='text-container'>
<p>...</p>
<p>...</p>
</span>
Then with css
.text-container {
display: flex;
flex-direction: row;
}