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

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>

Related

Align tex with heigh of icon

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
}

I use image and text side by side in footer but it creates problem when window is resized

Image after resize:
I use this code in my footer section. I have an image and some content side by side using media object class in bootstrap 4, but when the window is resized, the image and the content do not remain same and it creates a problem.
Here is my code:
<div class="col-lg-3 col-md-3 col-sm-6 mt-5">
<h5>Product</h5>
<div class="media">
<div class="media-left">
<a href="#"><img class="media-object"
src="./assets/Img/prod.png" alt="..."></a>
</div>
<div class="media-body">
<h6>vulputate velit consequat. </h6>
<div class="text-primary">
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
</div>
<span><s>Rs1200.00</s> Rs1000.00 </span>
</div>
</div>
</div>
Image I actually want:
Would you mind using only CSS instead of using Bootstrap? If no, then you may check out this answer. I have written the code in pure HTML and CSS:
.container {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: #2F2F2F;
font-family: Arial;
color: white;
}
.img1 {
width: 20%;
padding-left: 10px;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<title>Title of the page</title>
</head>
<body>
<div class="container">
<h2 style="padding: 10px;">Product</h2>
<img src="https://camo.githubusercontent.com/09e55b5e6a65a3ba9e38ed4de0f96ddd8ad46ba5c57b3e94d05222e0f127402a/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f323037383234352f3235393331332f35653833313336322d386362612d313165322d383435332d6536626439353663383961342e706e67"
class="img1">
<p>vulputate velit consequat</p>
<h3>⭐⭐⭐⭐⭐</h3>
<span><s>Rs 1200</s> Rs 1000</span>
</div>
</body>
</html>

Bootstrap 4 columns not stacking when screen is resized [duplicate]

This question already has answers here:
Bootstrap columns stacking vertically on mobile device
(2 answers)
Bootstrap 4.0 Grid System Layout not working
(1 answer)
Closed 4 years ago.
I can't seem to get my head around why the divs are not stacking on top of each other when I re size the screen.
I'm using col-xs-4 col-md-4 col-lg-4 but the content stays in one row and doesn't even resize.
<div class="container">
<div class="row">
<div class="info">
<div class="col-xs-4 col-md-4 col-lg-4">
<div class="logo-link"><img alt="Spartan Safety Logo" class="img-fluid" src="img/logo.png">
</div>
</div>
<div class="col-xs-4 col-md-4 col-lg-4">
<div class="info-center-1">
<div class="info-center-icon">
<i class="fa fa-phone-square fa-2x"></i>
</div>
<div class="info-center-title">
<h6>Customer Support and Sales</h6>
</div>
<div class="info-center-text">
<p>0208 5275888</p>
</div>
</div>
</div>
<div class="col-xs-4 col-md-4 col-lg-4">
<div class="info-center-1">
<div class="info-center-icon">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<div class="info-center-title">
<h6>Opening Hours</h6>
</div>
<div class="info-center-text">
<p>Mon - Fri 08:30 - 4:30</p>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
.info {
display: inline-flex;
margin: 20px 0px 10px 0px;
}
.logo-link img {
max-width: 50%;
height: auto;
margin-bottom: 10px;
}
.info-center-1 {
margin-top: 20px;
}
.info-center-icon i {
color: #cccccc;
display: inline-flex;
}
.info-center-title {
margin-bottom: px;
}
.info-center-title h6 {
font-family: 'Open Sans', Helvetica, Arial, sans-serif;
font-size: 16px;
font-weight: 400;
font-style: normal;
line-height: 22px;
text-transform: uppercase;
display: inline-flex;
}
.info-center-text p {
font-family: 'Open sans', sans-serif;
font-size: 24px;
font-weight: 400;
color: #FF9900;
line-height: 22px;
display: inline-flex;
}
You should not add more divs between .row and .col-. Instead, merge both info and row so you only have one wrapper for the col- divs:
<div class="container">
<div class="row info">
<div class="col-xs-4 col-md-4 col-lg-4">
<div class="logo-link"><img alt="Spartan Safety Logo" class="img-fluid" src="img/logo.png">
</div>
</div>
<div class="col-xs-4 col-md-4 col-lg-4">
<div class="info-center-1">
<div class="info-center-icon">
<i class="fa fa-phone-square fa-2x"></i>
</div>
<div class="info-center-title">
<h6>Customer Support and Sales</h6>
</div>
<div class="info-center-text">
<p>0208 5275888</p>
</div>
</div>
</div>
<div class="col-xs-4 col-md-4 col-lg-4">
<div class="info-center-1">
<div class="info-center-icon">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<div class="info-center-title">
<h6>Opening Hours</h6>
</div>
<div class="info-center-text">
<p>Mon - Fri 08:30 - 4:30</p>
</div>
</div>
</div>
</div>
Working example: http://jsfiddle.net/aq9Laaew/34182/
If you want a column to take the whole width of the row for a particular screen size then you should specify col-ScreenSize-12. So you should be using col-xs-12 col-md-4 col-lg-4 instead.
And also display: inline-flex; styling on class .info is making the division to be in a single line always, so remove it.

CSS: + selector not working when hover on child

I know this question is ask many time before but i didn't get the answers as i expected.... I am trying to hover on .h4size and effect on .fsize i use below css its not working...
HTML
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="div-square">
<a href="product.php" >
<i class="fa fa-qrcode fa-3x fsize"></i>
<h4 class="h4size">Saloon Product</h4>
</a>
</div>
CSS
.h4size:hover .fsize {
color: #c90000;
text-shadow: 4px 6px 3px #202020;
}
i also tried
.div-square .fsize .h4size:hover + .div-square .fsize {
color: #c90000;
text-shadow: 4px 6px 3px #202020;
}
its also not working
You can reverse the html code but have it display the way you originally intended with display: flex; and flex-direction: column-reverse;
Then use the adjacent sibling selector '+' to target the <i> tag from the <h4> tag.
a { text-decoration: none; color: black; }
.reorder {
display: flex;
flex-direction: column-reverse;
}
h4:hover + i {
color: red;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="div-square">
<a class="reorder" href="product.php">
<h4 class="h4size">Saloon Product</h4>
<i class="fa fa-qrcode fa-3x fsize"></i>
</a>
</div>
</div>
Another option is using flexbox and order
Here's the original answer..
https://stackoverflow.com/a/39157544/3377049
fiddle
https://jsfiddle.net/Hastig/9nvgvnxx/
More about flexbox at CSS Tricks
Hello Here is solution :
https://jsfiddle.net/uvzqsggo/
Replace your HTML code with below:
Just : <i class="fa fa-qrcode fa-3x fsize">Test</i> this line :
I have add sample text Test but remove it(this is just for example)
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="div-square">
<a href="product.php" >
<h4 class="h4size">Saloon Product</h4>
<i class="fa fa-qrcode fa-3x fsize">Test</i>
</a>
</div>
Your code should be like this:
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="div-square">
<a href="product.php">
<h4 class="h4size"> <i class="fa fa-qrcode fa-3x fsize"></i> Saloon Product</h4>
</a>
</div>
</div>
.fsize>.h4size:hover {
color: #c90000;
text-shadow: 4px 6px 3px #202020;
}
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="div-square">
<a href="product.php" >
<i class="fa fa-qrcode fa-3x fsize">
<h4 class="h4size">Saloon Product</h4></i>
</a>
</div>
This the easiest solution of your problem

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