How to align font awesome and text using flex box - html

I'm doing some homework and I'm trying to reproduce this
right here
this is my code
<div class="filterbar">
<p>Filtres</p>
<button class="buttonfilter Eco"> <i class="fas fa-money-bill-wave fa-2x"></i> Economique</button>
<button class="buttonfilter Fam"> <i class="fas fa-child fa-2x"></i>Famillial</button>
<button class="buttonfilter Rom"> <i class="fas fa-heart fa-2x"></i>Romantique</button>
<button class="buttonfilter Pet"> <i class="fas fa-dog fa-2x"></i>Animaux autorisé</button>
</div>
CSS right here
.filterbar{
display: flex;
max-width: 1100px;
margin: 0 auto;
overflow: auto;
}
.filterbar p {
font-weight: bold;
font-size: 18px;
margin-top: 10px;
margin-right: 20px;
}
.buttonfilter{
display: flex;
align-items: stretch;
height: 50px;
background: none;
border: 4px solid var(--background);
border-radius: 30px;
padding: 0;
}
.fa-money-bill-wave,.fa-child,.fa-heart,.fa-dog {
color: var(--primary-color);
background: rgba(0,101,252,0.2);
border-radius: 100px;
}
and the thing is that I can't align the font awesome icon and the text, and the background of the font awesome is so strange I really don't understand

I have litte modified your code:
.filterbar{
display: flex;
max-width: 1100px;
width: 1100px;
margin: 0 auto;
overflow: auto;
justify-content: space-between;
}
.filterbar p {
font-weight: bold;
font-size: 18px;
margin-top: 10px;
margin-right: 20px;
}
.buttonfilter{
display: flex;
align-items: stretch;
height: 50px;
background: none;
border: 4px solid var(--background);
border-radius: 30px;
padding: 0;
align-items: center;
border: 1px solid #333;
padding-right: 10px;
}
.fa-money-bill-wave,.fa-child,.fa-heart,.fa-dog {
color: var(--primary-color);
background: rgba(0,101,252,0.2);
border-radius: 100px;
padding: 10px;
margin-right: 10px;
width: 35px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<div class="filterbar">
<p>Filtres</p>
<button class="buttonfilter Eco"> <i class="fas fa-money-bill-wave fa-2x"></i> Economique</button>
<button class="buttonfilter Fam"> <i class="fas fa-child fa-2x"></i>Famillial</button>
<button class="buttonfilter Rom"> <i class="fas fa-heart fa-2x"></i>Romantique</button>
<button class="buttonfilter Pet"> <i class="fas fa-dog fa-2x"></i>Animaux autorisé</button>
</div>

To show the fontawsome Icons you need to put in the source like this:
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous
This worked for me:
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<i class="fas fa-money-bill-wave fa-2x"></i><button>Economique</button>
<i class="fas fa-child fa-2x"></i>
<button>Famillial</button>
<i class="fas fa-heart fa-2x"></i>
<button>Romantique</button>
<i class="fas fa-dog fa-2x"></i>
<button>Animaux autorise</button>
I think at this point you can adjust it yourself :)

Related

how to inline two border

this is my code:
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
}
body, html, #app, .Main {
height: 100%;
}
.Main {
display: flex;
overflow: hidden;
}
.side-bar {
display: flex;
flex-direction: column;
flex-basis: 80px;
align-items: center;
margin: auto 0;
height: 98%;
box-shadow: 2px 0 2px -1.8px rgb(0, 0, 0, 0.4);
}
.side-bar .icon {
font-size: 40px;
}
.side-bar .icon:first-child {
text-align: center;
padding-bottom: 20px;
width: 85%;
border-bottom: 1.5px solid rgb(0, 0, 0, 0.4);
}
.side-bar .icon:not(:first-child) {
margin-top: 20px;
}
.side-bar .icon:last-child {
margin-top: auto;
}
.side-bar .active {
color: rgb(0, 255, 170, 0.7);
}
.top-bar {
display: flex;
flex-direction: row;
height: 72.4px;
justify-content: center;
margin:0 auto;
width: 95.1%;
border-bottom: solid 2px rgb(0, 0, 0, 0.4);
}
<!DOCTYPE html>
<html>
<head>
<link href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" rel="stylesheet"/>
</head>
<body>
<div id="app">
<div class="Main">
<div style="display: flex; width: 100%;">
<div class="side-bar">
<i class="fad fa-home-alt icon"></i>
<i class="fad fa-th-large icon"></i>
<i class="fad fa-keyboard icon"></i>
<i class="fas fa-folder icon active"></i>
<i class="fad fa-power-off icon"></i>
</div>
<div class="top-bar">
<i class="side-bar fad fa-home-alt icon"></i>
<i class="side-bar fad fa-th-large icon"></i>
<i class="side-bar fad fa-keyboard icon"></i>
<i class="side-bar fas fa-folder icon active"></i>
<i class="side-bar fad fa-power-off icon"></i>
</div>
</div>
</div>
</div>
</body>
</html>
and this is what i spec to happen:
it's working but the problem is when i zoom in or out the borders width and position change, like this:
how can i change the borders width and position that when i zoom in or out the borders width and position does't change and get the same result as the first image.
just add margin-top to .side-bar .icon:first-child :
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
}
body, html, #app, .Main {
height: 100%;
}
.Main {
display: flex;
overflow: hidden;
}
.side-bar {
display: flex;
flex-direction: column;
flex-basis: 80px;
align-items: center;
margin: auto 0;
height: 98%;
box-shadow: 2px 0 2px -1.8px rgb(0, 0, 0, 0.4);
}
.side-bar .icon {
font-size: 40px;
}
.side-bar .icon:first-child {
text-align: center;
padding-bottom: 20px;
width: 85%;
border-bottom: 1.5px solid rgb(0, 0, 0, 0.4);
margin-top: 8px;
}
.side-bar .icon:not(:first-child) {
margin-top: 20px;
}
.side-bar .icon:last-child {
margin-top: auto;
}
.side-bar .active {
color: rgb(0, 255, 170, 0.7);
}
.top-bar {
display: flex;
flex-direction: row;
height: 72.4px;
justify-content: center;
margin:0 auto;
width: 95.1%;
border-bottom: solid 2px rgb(0, 0, 0, 0.4);
}
<!DOCTYPE html>
<html>
<head>
<link href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" rel="stylesheet"/>
</head>
<body>
<div id="app">
<div class="Main">
<div style="display: flex; width: 100%;">
<div class="side-bar">
<i class="fad fa-home-alt icon"></i>
<i class="fad fa-th-large icon"></i>
<i class="fad fa-keyboard icon"></i>
<i class="fas fa-folder icon active"></i>
<i class="fad fa-power-off icon"></i>
</div>
<div class="top-bar">
<i class="side-bar fad fa-home-alt icon"></i>
<i class="side-bar fad fa-th-large icon"></i>
<i class="side-bar fad fa-keyboard icon"></i>
<i class="side-bar fas fa-folder icon active"></i>
<i class="side-bar fad fa-power-off icon"></i>
</div>
</div>
</div>
</div>
</body>
</html>

Responsive text field with icons and counter field

I am trying to create an input field where user can increment or decrement the number. The input field should look like following design in a responsive way
However, it looks weird when I did the following way
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<div class="input-with-icon">
<div class="labelled-input">
<div class="labelling">
<div class="content">
<i class="fa fa-user fa-lg fa-fw" aria-hidden="true"></i>
<div class="text-wrapper">
<p class="adult">Adult</p>
<p>16+year</p>
</div>
</div>
</div>
<div class="augment">
<i class="fa fa-minus"></i>
</div>
<input type="text" class="input" disabled/>
<div class="augment">
<i class="fa fa-plus"></i>
</div>
</div>
</div>
Here is the demo
https://jsbin.com/fiwabararo/edit?html,css,output
Please check this code snippet
function counter(i){
var el =document.getElementsByClassName('input');
(i == '+')
? el[0].value = parseInt(el[0].value) + 1
: el[0].value = parseInt(el[0].value) - 1;
}
.input-with-icon {
position: relative;
width: 100%;
display: flex;
}
.labelled-input {
position: relative;
font-weight: 400;
font-style: normal;
display: inline-flex;
border: solid 1px #99acbd;
border-radius: 2px;
background:#eceef2;
}
.labelling {
display: inline-block;
line-height: 1;
vertical-align: baseline;
background-image: none;
color: rgba(0, 0, 0, 0.6);
text-transform: none;
font-weight: 700;
border: 0 solid transparent;
flex: 0 0 auto;
margin: 0;
}
.labelling:first-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.content {
display: flex;
align-items: center;
padding:0 12px
}
.augment {
background: #ccd5de;
text-align:center;
cursor: pointer;
height: 40px;
width: 40px;
border-radius: 50%;
margin: 10px;
margin-top:18px
}
.augment:hover {
background: #478dcf;
}
.augment i {
line-height:2.6;
color:#fff
}
.input {
margin: 0;
border: none;
outline: 0;
box-shadow: none;
font-size: 22px;
font-weight: bold;
text-align: center;
}
.input:disabled {
background: #fff;
}
#media(max-width:480px){
.input {
width:56%;
}
.augment {
width: 14%;
}
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<div class="input-with-icon">
<div class="labelled-input">
<div class="labelling">
<div class="content">
<i class="fa fa-user fa-lg fa-fw" aria-hidden="true"></i>
<div class="text-wrapper">
<p class="adult">Adult</p>
<p>16+year</p>
</div>
</div>
</div>
<div class="augment" onclick="counter('-')">
<i class="fa fa-minus"></i>
</div>
<input type="text" class="input" disabled value="0" />
<div class="augment" onclick="counter('+')">
<i class="fa fa-plus"></i>
</div>
</div>
</div>

How to resize list-style-images?

Just doing some practice by recreating the tumblr website, Im having some issues with the right side where it says "Recommended Blogs". I want to implement the use of a small user icon logo instead of the list style bullet. Is it possible to resize the images in css? or would i have to resize the image in photoshop?
Take a look at My Code pen
HTML
<html>
<head>
<title>Tumblr</title>
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<link rel="stylesheet" type="text/css" href="tumblrstyle.css">
</head>
<body>
<!-- Header Navigation -->
<div class="top-head">
<header>
<div id="top-head-left">
<h1>T</h1>
<input type="text" name="" placeholder="">
<i class="fas fa-search"></i>
</div>
<div id="top-head-right">
<i class="fas fa-home fa-2x"></i>
<i class="far fa-compass fa-2x"></i>
<i class="fas fa-envelope fa-2x"></i>
<i class="far fa-comment fa-2x"></i>
<i class="fas fa-bolt fa-2x"></i>
<i class="fas fa-user fa-2x"></i>
</div>
</header>
</div>
<!-- End Header -->
<!-- RightBar -->
<div class="container">
<div class="right-side">
<div class="right-side nav">
<h3>Recommended Blogs</h3>
<ul id="navi">
<li>empty</li>
<li>empty</li>
<li>empty</li>
<li>empty</li>
</ul>
</div>
<div class="radar">
<h3>radar</h3>
<ul>
<li>empty</li>
<p>
</p>
</ul>
</div>
</div>
<!-- Post Controls -->
<div class="controller">
<img src="https://image.freepik.com/free-vector/abstract-summer-sun-logo- design_1436-184.jpg">
<div class="post-group">
<div class="icons">
<i class="fas fa-home fa-5x"></i>
</div>
<div class="icons">
<i class="far fa-compass fa-5x"></i>
</div>
<div class="icons">
<i class="fas fa-envelope fa-5x"></i>
</div>
<div class="icons">
<i class="far fa-comment fa-5x"></i>
</div>
<div class="icons">
<i class="fas fa-bolt fa-5x"></i>
</div>
<div class="icons">
<i class="fas fa-user fa-5x"></i>
</div>
</div>
</div>
</body>
</html>
CSS
/*Reset*/
* {
margin: 0;
padding: 0;
}
body {
background: lightgray;
}
header {
padding: 0 10px;
}
header h1 {
display: inline;
margin-right: 15px;
}
.container {
width: 60%;
margin: auto;
overflow: visible;
}
div h3 {
border-bottom: 1px solid black;
}
/*Header*/
.top-head {
background: lightblue;
height: 60px;
border-bottom: 5px solid black;
padding: 0px 20px;
}
#top-head-left {
float: left;
padding-top: 5px;
}
#top-head-left input[type="text"] {
width: 200px;
background: yellow;
padding: 5px 0px;
}
#top-head-right {
float: right;
padding-top: 12px;
}
/*RightsideBar*/
.right-side {
float: right;
}
.nav ul {
list-style-image: url('https://78.media.tumblr.com/avatar_0f16d6a6a019_128.pnj');
}
.nav ul li {
}
.radar ul {
list-style: none;
}
/*Post Controller*/
.controller {
margin-top: 50px;
}
.controller img {
width: 10%;
float: left;
margin-right: 20px;
border-radius: 10px;
}
.post-group {
float: left;
background: white;
height: 68px;
border-radius: 10px;
padding-top: 8px;
padding-bottom: 22px;
}
.icons {
float: left;
}
.icons a {
color: orange;
padding: 0 12px;
}
/* https://78.media.tumblr.com/avatar_3aed9115be2f_128.pnj
https://78.media.tumblr.com/avatar_0f16d6a6a019_128.pnj
https://78.media.tumblr.com/avatar_0f16d6a6a019_128.pnj
https://78.media.tumblr.com/avatar_996dede0302e_128.pnj */
#navi {
list-style-type: none;
}
#navi > li::before {
content: '';
display: inline-block;
height: 40px;
width: 40px;
background-size: 40px;
background-image: url('https://78.media.tumblr.com/avatar_0f16d6a6a019_128.pnj');
background-repeat: no-repeat;
margin-right: 10px;
background-position: center center;
vertical-align: middle;
}
Please don't mind my selectors

How to create a grey background for the social icon on the center?

My icons look like this:
I need to create like this one:
Here is my HTML:
<aside class="social">
<span><i class="fa fa-instagram" aria-hidden="true"></i></span>
<span><i class="fa fa-facebook" aria-hidden="true"></i></span>
<span><i class="fa fa-pinterest" aria-hidden="true"></i></span>
</aside>
Here is my CSS:
aside.social a {
margin-left: 10px;
color: #fff;
font-size: 16px;
}
aside.social a span {
width: 25px;
display: inline-block;
height: 25px;
background-color: #aaa;
border-radius: 40%;
}
You don't need two separate elements, you can do that all on your a with an i.fa inside.
aside.social a {
color: #fff;
background: #aaa;
margin-left: 10px;
border-radius: 40%;
width: 25px;
height: 25px;
line-height: 25px; /* vertical alignment */
text-align: center;
font-size: 16px;
}
I would use inline-flex on that element, then you can use flex positioning to center. justify-content: center; align-items: center; will center horizontally and vertically. You can also change the border-radius to 50% for a true circle.
aside.social a {
margin-left: 10px;
color: #fff;
font-size: 16px;
text-decoration: none;
}
aside.social a span {
width: 25px;
height: 25px;
background-color: #aaa;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<aside class="social">
<span><i class="fa fa-instagram" aria-hidden="true"></i></span>
<span><i class="fa fa-facebook" aria-hidden="true"></i></span>
<span><i class="fa fa-pinterest" aria-hidden="true"></i></span>
</aside>
Try changing your code so it looks something like this
span {
display: block;
text-align: center;
line-height: 25px
}
And
a {
width: 25px;
height: 25px;
display: inline-block;
}
You can use flex:
aside.social a {
margin-left: 10px;
color: #fff;
font-size: 16px;
text-decoration: none;
}
aside.social a span {
display: inline-flex;
justify-content: center;
align-items: center;
width: 25px;
height: 25px;
background-color: #aaa;
border-radius: 40%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<aside class="social">
<a href="https://www.instagram.com/" class="inst">
<span>
<i class="fa fa-instagram" aria-hidden="true"></i>
</span>
</a>
<a href="https://www.facebook.com" class="facb">
<span>
<i class="fa fa-facebook" aria-hidden="true"></i>
</span>
</a>
<a href="https://www.pinterest.com/" class="pint">
<span>
<i class="fa fa-pinterest" aria-hidden="true"></i>
</span>
</a>
</aside>
add this in "aside.social a span", nothing else is required:
text-align:center;
padding-top:8px;
Try adding a position: absolute; to the css
Followed by margin-left: 20px, play with the pixels a little until you're satisfied :)

Aligning a toolbar with search text box using font awesome

I am trying a make a toolbar using font awesome with a few icons and search text box at the start.
I would like this to be ideally aligned in a way that it has search on the left most followed by the icons to its right.
.icon-bar {
width: 40%;
text-align: center;
background-color: #555;
overflow: auto;
display:flex;
}
.icon-bar a {
width: 15%;
padding: 12px 0;
float: left;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.icon-bar a:hover {
background-color: #000;
}
#filtersubmit {
position: relative;
z-index: 1;
left: -25px;
top: 1px;
color: #7B7B7B;
cursor: pointer;
width: 0;
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<div class="icon-bar">
<input id="searchInput" type="text" placeholder="Search" /><i id="filtersubmit" class="fa fa-search"></i>
<i class="fa fa-envelope"></i>
<i class="fa fa-globe"></i>
<i class="fa fa-trash"></i>
<a class="active" href="#"><i class="fa fa-home"></i></a>
</div>
</div>
Ideally I would like to be aligned like this image below:
Changes as per the solution below:
Menu with full browser screen:
Now when I minimize the browser the scroll comes which is because of overflow:auto.
Is their a way I can control the width of the search box for the icons I think changing the fontsize does the trick.
Add display flex to the .icon-bar div.
.icon-bar {
width: 30%;
text-align: center;
background-color: #555;
overflow: auto;
display:flex;
}
Also, as dipas noted remove that position left.
It is easier using inline-blocks:
.icon-bar {
text-align: center;
background-color: #555;
overflow: auto;
}
.icon-bar a {
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.icon-bar a:hover {
background-color: #000;
}
#filtersubmit {
color: #7B7B7B;
cursor: pointer;
}
.icon-bar > * {
display: inline-block;
vertical-align: middle;
padding: 10px;
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
<div>
<div class="icon-bar">
<input id="searchInput" type="text" placeholder="Search" /><i id="filtersubmit" class="fa fa-search"></i>
<i class="fa fa-envelope"></i>
<i class="fa fa-globe"></i>
<i class="fa fa-trash"></i>
<a class="active" href="#"><i class="fa fa-home"></i></a>
</div>
</div>
You can use flexboxes too:
.icon-bar {
text-align: center;
background-color: #555;
overflow: auto;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
width: 60%;
}
.icon-bar a {
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.icon-bar a:hover {
background-color: #000;
}
#filtersubmit {
color: #7B7B7B;
cursor: pointer;
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
<div>
<div class="icon-bar">
<input id="searchInput" type="text" placeholder="Search" /><i id="filtersubmit" class="fa fa-search"></i>
<i class="fa fa-envelope"></i>
<i class="fa fa-globe"></i>
<i class="fa fa-trash"></i>
<a class="active" href="#"><i class="fa fa-home"></i></a>
</div>
</div>
Use display: table on parent .icon-bar and display: table-cell on children groups .search-bar and .button-wrapper
.icon-bar {
display: table;
padding: 0 20px;
background-color: #555;
overflow: auto;
}
.search-bar, .button-wrapper {
display: table-cell;
vertical-align: middle;
}
#filtersubmit {
color: #7B7B7B;
cursor: pointer;
}
.button-wrapper a {
display: inline-block;
padding: 12px;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.button-wrapper a:hover {
background-color: #000;
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<div class="icon-bar">
<div class="search-bar">
<input id="searchInput" type="text" placeholder="Search" />
<i id="filtersubmit" class="fa fa-search"></i>
</div>
<div class="button-wrapper">
<i class="fa fa-envelope"></i>
<i class="fa fa-globe"></i>
<i class="fa fa-trash"></i>
<a class="active" href="#"><i class="fa fa-home"></i></a>
</div>
</div>
</div>