I am new to HTML, CSS and bootstrap and trying to make a page something like this.
..............................................................................................................................................................
Header
..............................................................................................................................................................
And after this Header I need a rectangle in my page with some text and a button.
Specification I need to follow for this rectangle are as follows:
Here is my code:
.rectangle {
width: 632px;
height: 269px;
border-radius: 4px;
border: solid 1px #e0e0e0;
background-color: #ffffff;
text-align: center;
}
.Find-your-number {
width: 468px;
height: 23px;
font-size: 18px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: 1.28;
letter-spacing: -0.03px;
text-align: center;
color: #333333;
}
.btn-bg {
width: 303px;
height: 48px;
border-radius: 4px;
background-color: #f9c940;
}
.open {
width: 291px;
height: 54px;
font-size: 49px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: 1.1;
letter-spacing: -0.8px;
text-align: center;
color: #333333;
padding-top: 5%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-12 pt-md-5 text-center">
<div class="rectangle">
<p class="open">Open here</p>
<p class="find-your-number">Find your number</p>
<button class="btn-bg">Start</button>
</div>
</div>
</div>
</div>
This rectangle should be at 250px
from top and 196px
from side. How can I get it?
As of now I am getting rectangle towards a bit left side of page.
Also, text inside rectangle also not taking proper font size and alignment as mentioned in CSS. How can I correct it?
2
Answers
with or without pingendo.com you should try this (to all devices)
To achieve what from the picture that you shared, you can do it manually with pure CSS or by using bootstrap. I chose the pure CSS approach, so for this cause you will need to use
flexbox
and the related attributes with it suchalign-items
andjustify-contents
and set them tocenter
to achieve the center align.There are some other approaches to achieve this like using
table
andvertical-align
and some other.EDIT:
Implementation with bootstrap
In this approach, you just need to visit bootstrap website and then add the related CDNs to your project, then you have to just add
d-flex
,align-items-center
, andjustify-content-center
to the main container of your page.