I am new to coding and I was practicing landing page. Right now I am stuck here. As I explained in the title I have problems with CSS and maybe made a mistake in html
.last-page {
background-color: #3882f6;
font-size: 18px;
color: aliceblue;
padding: 10px;
display: flex;
margin-right: 150px;
margin-left: 150px;
margin-top: 50px;
}
.button {
background-color: #3882f6;
color: rgb(255, 255, 255);
display: flex;
justify-content: center;
align-items: center;
height: 20px;
}
.text {
margin-right: 75px;
margin-left: 75px;
margin-top: 25px;
}
<div class="last-page">
<div class="text">
<p> <strong>Time to action! It's time!</strong> <br> Sign up for our product by clicking that button right over there</p>
</div>
<button class="last-page button">Sign Up</button>
</div>
3
Answers
If you want to put the text higher, you can reduce the value of
margin-top
. And useposition:absolute;right:10px;
to put the button right of the container.Try this:
Click the following link to preview:
preview image
To make the text a little higher, add a negative top margin to the ".text" class:
.text {
margin: -20px 75px 0 75px;
}
To make the blue square with circled edges add "border-radius" to the ".last-page".
To place "Sign Up" on the right side, use "justify-content" also on the ".last-page"
By the way, ".last-page" is a poor name. It’s best to choose a name that clearly reflects the component or page and its functionality, so that it can be easily recognized even after several years without the need to remember what the app is. Good luck with your learning!
I would suggest a grid here since it allows you to control a lot and yet still keep it responsive.
display: grid; place-items: center;
which "super centers" the span inside of that. Change the button size and see what happens; no need for any fancy re-center margin adjustment or fragile positioning.16px
) and set some defaults.p
with a div since you seemed to what a "header" and "text"10rem
now which is 160px (see why I set the default in the body?)1rem;
can be whatever you want..action-text
I set the margins to thep
default so it can be whatever you style it to.1fr
etc. to the right or put a right margin as needed to place it better;Be sure to show this in "full page" here and re-size the browser so you can see how it reacts to that.