\n
* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nhtml {\n font-size: 62.2%;\n font-family: Roboto, Arial, Helvetica, sans-serif;\n}\n\n.follow__container {\n display: grid;\n place-items: center;\n height: 100vh;\n}\n\n.follow__content {\n background-color: rgba(206, 194, 178, 0.836);\n line-height: 1.2;\n padding: 2rem 10rem;\n}\n\n.img__container {\n width: 35px;\n display: inline-block;\n margin-right: 2rem;\n margin-top: 0.5rem;\n}\n\n.img__container img {\n width: 35px;\n height: 35px;\n object-fit: cover;\n object-position: center;\n border-radius: 5rem;\n}\n\n.follow__desc {\n display: inline-block;\n margin: 0 0 0 0.5rem;\n font-size: 0.99rem;\n}\n\n.follow__btn {\n display: inline-block;\n font-size: 1.2rem;\n left: 8rem;\n position: relative;\n top: -1.6rem;\n cursor: pointer;\n}\n\n.follow__btn a {\n text-decoration: none;\n padding: 1rem 1.5rem;\n background-color: #222095;\n color: #ffffff;\n border-radius: 1rem;\n}
\r\n<div class=\"follow__container\">\n <div class=\"follow__content\">\n\n <div class=\"img__container\">\n <img src=\"cybercybrog.jpg\" alt=\"\">\n </div>\n\n <div class=\"follow__desc\">\n <h2>Mr Cyborg</h2>\n <p>#CyberCity</p>\n <p>Most Popular</p>\n </div>\n\n <div class=\"follow__btn\">\n <a href=\"#\">Follow</a>\n </div>\n\n </div>\n</div>
\r\nReputation: 55
I made this followers Card design but am having a bit of problem when styling it, when I try to add margin-right
to align the image to the right side of the container for some reason it doesn't align to the right, It aligns it more to the left and it stretches the container, it also grabs the text even though they're both in separate containers, same for the button. And for some reason instead of using padding on the follow__content
, I instead used gave a width but for some reason the image get left out.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
.follow__container {
display: grid;
place-items: center;
height: 100vh;
}
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 2rem 10rem;
}
.img__container {
width: 35px;
display: inline-block;
margin-right: 2rem;
margin-top: 0.5rem;
}
.img__container img {
width: 35px;
height: 35px;
object-fit: cover;
object-position: center;
border-radius: 5rem;
}
.follow__desc {
display: inline-block;
margin: 0 0 0 0.5rem;
font-size: 0.99rem;
}
.follow__btn {
display: inline-block;
font-size: 1.2rem;
left: 8rem;
position: relative;
top: -1.6rem;
cursor: pointer;
}
.follow__btn a {
text-decoration: none;
padding: 1rem 1.5rem;
background-color: #222095;
color: #ffffff;
border-radius: 1rem;
}
<div class="follow__container">
<div class="follow__content">
<div class="img__container">
<img src="cybercybrog.jpg" alt="">
</div>
<div class="follow__desc">
<h2>Mr Cyborg</h2>
<p>#CyberCity</p>
<p>Most Popular</p>
</div>
<div class="follow__btn">
<a href="#">Follow</a>
</div>
</div>
</div>
Upvotes: 1
Views: 196
Reputation: 164
I think this is your desired output.I used the padding property
in the follow__content
class and changed its' values by giving all the sides padding like this. Since you had given padding only for two sides it was applied incorrectly.
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 10px 100px 10px 10px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
.follow__container {
display: grid;
place-items: center;
height: 100vh;
}
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 20px 100px 20px 10px;
}
.img__container {
width: 35px;
display: inline-block;
margin-right: 0rem;
margin-top: 0.5rem;
}
.img__container img {
width: 35px;
height: 35px;
object-fit: cover;
object-position: center;
border-radius: 5rem;
}
.follow__desc {
display: inline-block;
margin: 0 0 0 0.5rem;
font-size: 0.99rem;
}
.follow__btn {
display: inline-block;
font-size: 1.2rem;
left: 8rem;
position: relative;
top: -1.6rem;
cursor: pointer;
}
.follow__btn a {
text-decoration: none;
padding: 1rem 1.5rem;
background-color: #222095;
color: #ffffff;
border-radius: 1rem;
}
<div class="follow__container">
<div class="follow__content">
<div class="img__container">
<img src="https://www.slashfilm.com/img/gallery/joss-whedon-says-he-cut-cyborgs-justice-league-storyline-because-ray-fisher-is-a-bad-actor/l-intro-1642457019.jpg" alt="Profile Image">
</div>
<div class="follow__desc">
<h2>Mr Cyborg</h2>
<p>#CyberCity</p>
<p>Most Popular</p>
</div>
<div class="follow__btn">
<a href="#">Follow</a>
</div>
</div>
</div>
Upvotes: 1