Align tex with heigh of icon - css

I use bootstrap 5
Instead of having text below icon, I would like text align verticaly with icon heigh
h3 {
text-align: center;
}
.testHead {
background-color: #5c636a;
color: white;
text-align: center;
}
.testHead .col {
font-size: 1.2rem!important;
}
.testHead i {
font-size: 4rem!important;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.3.0/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<nav class="testHead">
<h3>For a few dollar</h3>
<br>
<div class="row">
<div class="col ">
<i class="bi bi-display"></i> Answer simple question
</div>
<div class="col">
<i class="bi bi-download"></i> Download and print
</div>
<div class="col">
<i class="bi bi-clock"></i> It take less then 10 minutes
</div>
</div>
</nav>
Search to get something like

Make your elements flex, it's the easiest solution.
Add these Bootstrap classes to your elements that need to be vertically centered like this :
<nav class="testHead">
<h3>For a few dollar</h3>
<br />
<div class="row">
<div class="col d-flex align-items-center">
<i class="bi bi-display"></i>
Answer simple question
</div>
<div class="col d-flex align-items-center">
<i class="bi bi-download"></i>
Download and print
</div>
<div class="col d-flex align-items-center">
<i class="bi bi-clock"></i>
It take less then 10 minutes
</div>
</div>
</nav>

or with simple CSS.
Surround your texts with a p tag, with a classname to give the margin-letf
Ex :
<div class="col d-flex align-items-center">
<i class="bi bi-display"></i>
<p class="descr">Answer simple question</p>
</div>
and then apply css to your <div class="col"> :
.col {
display:flex;
align-items:center;
}
.col .descr {
margin-left: 10px
}

Related

Bootstrap button is not working, Tried cursor pointer and (click), still didn't work

I'm new to Angular and Bootstrap, but I found a code from a website but when I put it in my project, the button did not work.
Any help would be appreciated.
<div class="container">
<div class="row">
<div class="col-12 col-sm-8 col-md-6 col-lg-4" *ngFor="let P of products">
<div class="card" *ngIf="P.Category == selectedCategory">
<img class="card-img" src="{{P.Img}}" alt="Vans">
<div class="card-img-overlay d-flex justify-content-end">
</div>
<div class="card-body">
<h4 class="card-title">{{P.Name}}</h4>
<h6 class="card-subtitle mb-2 text-muted">Serial No. {{P.SerialNumber}}</h6>
<p class="card-text">{{P.Description}}</p>
<div class="buy d-flex justify-content-between align-items-center">
<div class="price text-success"><h5 class="mt-4">${{P.Price}}</h5></div>
<button type="button" (click)="addToCart(P)" class="btn btn-danger mt-3 curs"> Add to Cart</button>
</div>
</div>
</div>
</div>
</div>
</div>
and this is the css code
body {
padding: 2rem 0rem;
}
.like {
font-size: 1.5rem;
}
Thanks in advance
did you insert the bootstrap CDN link for CSS? if not then paste this under your css file inside the head section
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">

Different icons in the circle are shown as eggs [duplicate]

This question already has answers here:
Font Awesome - how to put an icon inside a circle?
(2 answers)
Make Font Awesome icons in a circle border with right 1:1 ratio
(4 answers)
How to round font-awesome icons?
(3 answers)
Closed 2 years ago.
I would like to have three different icons displayed next to each other, as soon as I do this they are no longer round but more like an egg. How can I solve this problem?
HTML
<div class="row text-center">
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-rocket icon-fast"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-glasses icon-fast"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-lock icon-fast"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
</div>
CSS
.icon-fast {
font-size: 62px;
border-radius: 50%;
padding: 16px;
/* background-color: green;*/
background: linear-gradient(to bottom right, #035ff3, #550ca4);
color: white;
}
.services-title {
font-weight: normal;
}
.services-subtitle {
font-size: 17px;
}
As soon as I write the same icon three times, I get real circles. I would like to have this on three different ones?
You need to add display: inline-block; to the .icon-fast class in CSS. then set some a width and height equal. Also you can play around with your oadding to center it.
Check it out:
.icon-fast {
font-size: 62px;
border-radius: 50%;
padding: 10px;
/* background-color: green;*/
background: linear-gradient(to bottom right, #035ff3, #550ca4);
color: white;
display: inline-block;
height: 120px;
width: 120px;
}
.services-title {
font-weight: normal;
}
.services-subtitle {
font-size: 17px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="row text-center">
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-rocket icon-fast"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-rocket icon-fast"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-rocket icon-fast"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
</div>
Because i is an inline element, you have to make it block, by using d-inline-block utility class
If you need to set it centered, you can use d-inline-flex align-items-center justify-content-center in i
Also you need to set width as the same as height, to make a square
The size of the icon can be adjusted using font-size in pseudo element ::before
.icon-fast {
border-radius: 50%;
padding: 16px;
/* background-color: green;*/
background: linear-gradient(to bottom right, #035ff3, #550ca4);
color: white;
width: 62px;
height: 62px;
}
.icon-fast::before {
font-size: 30px/* change this as you need */
}
.services-title {
font-weight: normal;
}
.services-subtitle {
font-size: 17px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row text-center">
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-rocket icon-fast d-inline-flex align-items-center justify-content-center"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-ad icon-fast d-inline-flex align-items-center justify-content-center"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<i class="fas fa-atlas icon-fast d-inline-flex align-items-center justify-content-center"></i>
<h3 class="services-title">Head</h3>
<p class="text-black-50 services-subtitle">Some text for you, lalalalal.</p>
</div>
</div>
</div>

Align icon and two lines of text with materialize css

I need to align an icon with two lines of text, I am using MaterilizeCSS. This is my code but I can not solve it.
Any ideas?
<div class="col s12 m3 center">
<i class="material-icons">access_time</i>
<span>Horario</span><br>
<span>Helper text</span>
</div>
Attached picture to explain myself better
.d-flex {
display: flex
}
.text {
flex-direction: column;
margin-left: 10px;
}
.fa-map-marker.marker {
font-size: 35px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="col s12 m3 center d-flex">
<i class="fa fa-map-marker marker"></i>
<div class="d-flex text">
<span>Horario</span>
<span>Helper text</span>
</div>
</div>

Bootstrap footer is overlapping the content on small screens?

I have an issue with my bootstrap layout.
Basically, everything looks OK on larger screens but on smaller screens my footer overlaps the content or the content overlaps the footer!
This is the code I have: https://jsfiddle.net/xpvt214o/639029/
If you make the HTML part larger and smaller and look at the footer, you will see the issue.
This is my full code:
html,body,.col-md-12,.row {
height:100%;
}
.row > div {
height:100%;
}
.YOsidemenu{
padding:0;
font-weight:bold;
background-color: #ffc90e;
padding-top:10px;
max-width:200px;
}
#media only screen and (max-width:768px) {
.YOsidemenu{
display:none;
}
}
/* to make columns visible */
.row .col-sm-2 {
background-color:red;
}
.row .col-sm-10 {
background-color:green;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div style="height:100%; background:#fff;width:100%;padding:0;" class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2">
Sidebar content
</div>
<div class="col-sm-10">
Body content
</div>
</div>
</div>
</div>
<!-- Footer -->
<section id="footer" style="text-align:left; !important">
<div class="container">
<div class="row text-center text-xs-center text-sm-left text-md-left" style="text-align:left; !important">
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Quick links</h5>
<ul class="list-unstyled quick-links">
<li>Home</li>
<li>Help</li>
<li>Sign-in</li>
<li>affiliate</li>
<li>Promote</li>
</ul>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Support</h5>
<ul class="list-unstyled quick-links">
<li><i class="fa fa-envelope"></i>support#email.com</li>
<li><i class="fa fa-phone-square"></i>+44 7842227819</li>
<li><i class="fa fa-globe"></i>www.website.com</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 mt-2 mt-sm-2 text-center text-white">
<p>this site a registered company. </p>
<p class="h6">&copy All right Reversed.<a class="text-green ml-2" href="https://www.website.com" target="_blank">website</a></p>
</div>
</hr>
</div>
</div>
</section>
<!-- ./Footer -->
Could someone please be kind enough and help me with this issue?
Thanks in advance.
Try removing height: 100% from the div. On mobile the container is 100% high, but because the columns get stacked and each column inherits the height, you have a parent with 100% height and two columns with each 100%, making it 200% of height.
Is this what you are looking for?
html,
body,
.col-md-12,
.row {
height: 100%;
}
.row>div {
height: 100%;
}
.YOsidemenu {
padding: 0;
font-weight: bold;
background-color: #ffc90e;
padding-top: 10px;
max-width: 200px;
}
#media only screen and (max-width:768px) {
.YOsidemenu {
display: none;
}
}
/* to make columns visible */
.row .col-sm-2 {
background-color: red;
}
.row .col-sm-10 {
background-color: green;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div style="height:100%; background:#fff;width:100%;padding:0;" class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2 col-xs-2">
Sidebar content
</div>
<div class="col-sm-10 col-xs-10">
Body content
</div>
</div>
</div>
</div>
<!-- Footer -->
<section id="footer" style="text-align:left; !important">
<div class="container">
<div class="row text-center text-xs-center text-sm-left text-md-left" style="text-align:left; !important">
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Quick links</h5>
<ul class="list-unstyled quick-links">
<li>Home</li>
<li>Help</li>
<li>Sign-in</li>
<li>affiliate</li>
<li>Promote</li>
</ul>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Support</h5>
<ul class="list-unstyled quick-links">
<li><i class="fa fa-envelope"></i>support#email.com</li>
<li><i class="fa fa-phone-square"></i>+44 7842227819</li>
<li><i class="fa fa-globe"></i>www.website.com</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 mt-2 mt-sm-2 text-center text-white">
<p>this site a registered company. </p>
<p class="h6">&copy All right Reversed.<a class="text-green ml-2" href="https://www.website.com" target="_blank">website</a></p>
</div>
</hr>
</div>
</div>
</section>
<!-- ./Footer -->

Why is this Bootstrap column acting up?

Why is the content nesting itself inside of each list item? The content should all be on the same line. I've tried floating and changing the position, but nothing is working. How do I fix this?
.icon-left{
float:left;
padding: 12px 25px 60px 15px;
color:#4ECABE;
}
.text{
text-align:left;
padding:0 0 0 15px;
}
.text h4{
padding-bottom:5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="icon-left">
<i class="fa fa-ticket fa-3x"></i>
</div>
<div class="text">
<h4>Get Free Books</h4>
<p>Increase your chances to win by doing simple tasks - like watching videos :) </p>
</div> <br>
<div class="icon-left" id='smile'>
<i class="fa fa-smile-o fa-3x"></i>
</div>
<div class="text2">
<h4>New Books Every 6 Hours</h4>
<p>That's right, you only have 6 hours to get entries for a book.</p>
</div> <br>
<div class="icon-left">
<i class="fa fa-truck fa-3x"></i>
</div>
<div class="text">
<h4>Absolutely free!</h4>
<p>We even pay shipping.</p>
</div>
</div>
You need to clear the floats. You can either apply br { clear: both; } with your existing markup, or a better way to do it with bootstrap is to wrap the .icon-left and .text elements in an element with the .clearfix class.
.icon-left{
float:left;
padding: 12px 25px 60px 15px;
color:#4ECABE;
}
.text{
text-align:left;
padding:0 0 0 15px;
}
.text h4{
padding-bottom:5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="clearfix">
<div class="icon-left">
<i class="fa fa-ticket fa-3x"></i>
</div>
<div class="text">
<h4>Get Free Books</h4>
<p>Increase your chances to win by doing simple tasks - like watching videos :) </p>
</div>
</div>
<div class="clearfix">
<div class="icon-left" id='smile'>
<i class="fa fa-smile-o fa-3x"></i>
</div>
<div class="text2">
<h4>New Books Every 6 Hours</h4>
<p>That's right, you only have 6 hours to get entries for a book.</p>
</div>
</div>
<div class="clearfix">
<div class="icon-left">
<i class="fa fa-truck fa-3x"></i>
</div>
<div class="text">
<h4>Absolutely free!</h4>
<p>We even pay shipping.</p>
</div>
</div>
</div>
Give your .icon-left divs a coloured background (e.g. background: gold) and it should become evident. The bottom padding extends past the non-float elements on the right, which is pushing the next row along.
Reducing the padding on .icon-left (for example to padding: 12px 25px 24px 15px;) should allow everything to snap back into line.
Slightly unrelated tip: add the class fa-fw to your FA icons to use fixed width icons, which will allow your text to line up perfectly.
you have extra padding icon-left
try padding: 12px 25px 25px 15px;
Also I would wrap every section with a div and a grid class col-lg-3 so you dont have to use this big padding, and will give you a better control on your UI.

Resources