Design comparison
Solution retrospective
Hello, everyone! This was my first project here and I had lots of fun. My question is about the text formatting as in, in how many lines the text is display as, or, where the lines break. I tried a few things like using the white-space property and the html <pre> tags. I'm not looking for a super detailed answer(although those would be greatly appreciated ) , just some pointers as to how I could've done it. So my question is, how could I have have achieved the same result without using the <br> tags? Thank you so very much for your time!
Here's my html:
<div class="body">
<p class="p-main">
Discover the benefits of data<br />
analytics and make better decisions<br />
regarding revenue customer<br />
experience, and overall efficiency.
</p>
<p class="p-main-large">
Discover the benefits of data analytics and make <br />better
decisions regarding revenue customer<br />
experience, and overall efficiency.
</p>
</div>
Then, I have a media query that "swaps" from one paragraph to the other when it gets to a certain size, by using the display property. I'm not proud of this solution, but I did what I could.
My sass
.p {
&-main {
color: $secondary-white;
line-height: 1.5;
// I really don't like this solution to obtain the right text formatting
// See mark up*
&-large {
display: none;
color: $secondary-white;
line-height: 1.5;
@include mq("huge") {
display: block;
}
}
@include mq("huge") {
display: none;
}
}
&-stats {
color: $tertiary-white;
text-transform: uppercase;
margin-top: 8px;
}
}
Community feedback
- @duartrosarPosted over 3 years ago
Hey, @jeepitou! Thank you very much for replying, I appreciate it.
Yeah, I did think about doing it your way, with the font-size and margin/padding, but I felt more comfortable doing it the hackish way, for some reason :)
I will definitely try and get off my comfort zone a bit more next time. Thanks for your help
0 - @jeepitouPosted over 3 years ago
I agree with @AgataLiberska. I just did this exercice and didn't use any <br> (altough I did think about it to be honest).
What I did is setup the font-size and margin/padding to have the line break at a very similar point.
I did have to do separate CSS for desktop&mobile, but I think my solution is a bit less hacky than yours.
Other than that, great work :)
0 - @AgataLiberskaPosted over 3 years ago
Hi @duartrosar - I think the fact that lines break in different points is not a massive issue to be honest - I think it's pretty normal on responsive pages. So if a few words are on different lines on different screen sizes - don't worry about it.
An exception to this would be when a heading or a tagline (a few lines of text under a heading) stretches so much that it looks a bit off and it loses some visual impact - to prevent that, I usually just set a
max-width
to the text element.0@duartrosarPosted over 3 years agoHi @AgataLiberska, thank you for your feedback, much appreciated. I did try and use max-width, but I get a bit confused sometimes when trying it, will definitely keep trying it though. Thank you
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord