.account-select-block {
display: flex;
width: 100%;
height: 50px;
line-height: 50px;
}
.account-select-icon {
flex: 0;
font-size: 20px;
}
.account-select-item {
flex: 1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
flex: 0;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
In the end icons are aligning vertically but text in the middle block doesn't
What am I doing wrong?
Fiddle: https://jsfiddle.net/7su954x3/
You need to remove the margin from the heading:
.account-select-block {
display: flex;
width: 100%;
height: 50px;
line-height: 50px;
}
.account-select-icon {
flex: 0;
font-size: 20px;
}
.account-select-item {
flex: 1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
flex: 0;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
/* add this */
.account-select-item h3 {
margin: 0;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
Didn't realise you were setting the line height manually to vertically centre, if you don't want to do that then you would have to make each child flex too and apply align items to them:
.account-select-block {
display: flex;
width: 100%;
height: 50px;
}
.account-select-icon {
display:flex;
align-items:center;
font-size: 20px;
}
.account-select-item {
display:flex;
align-items:center;
flex-grow:1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
display:flex;
align-items:center;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
/* add this */
.account-select-item h3 {
margin: 0;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
In your question you ask how to align in flexbox. However in your code .account-select-item is not a flexbox.
Instead you seem to be using an old styling 'hack' using line-height. This will fall apart if you ever decide to change .account-select-block's height or line-height.
.account-select-block {
display: flex;
width: 100%;
height: 50px;
/* line-height: 50px; */
}
.account-select-icon {
flex: 0;
font-size: 20px;
}
.account-select-item {
display: flex; /* NEW */
flex: 1;
align-items: center; /* NEW */
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
flex: 0;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
try with this
.account-select-item {
flex: 1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
Related
I tried to put the elements of social networks together and when I hover the mouse over each element it grows to a size of 200 pixels. I wrote all the code, but when the mouse is placed on the element, the element does not grow properly and looks like an ellipse. Is there anyone who can help me with this?
<style>
:root {
--color-orange: #ff6600;
--color-green: #22d122;
--color-cyan: #33ffff;
--color-magenta: #f33192;
--color-white: #ffffff;
--color-blue: #166fd4;
--color-magenta-dark:#831a4e;
--color-gray:#d6d6d6;
--color-red:#ff0000;
--color-graydark:#333;
--color-blue-dark:#103d68;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: "Nunito", sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: repeat(4, auto);
place-content: center;
width: 100%;
height: 100vh;
background-color: var(--color-gray);
}
.button {
display: inline-block;
background-color: var(--color-white);
width: 60px;
height: 60px;
overflow: hidden;
box-shadow: 0 10px 10px rgba(0,0,0,0.1);
transition: all 0.3s ease-out;
border-radius: 50%;
margin: 0 5px;
cursor: pointer;
}
.button:hover {
width: 200px;
}
.button .icon {
display: inline-block;
text-align: center;
font-size: 20px;
border-radius: 50%;
height: 60px;
width: 60px;
line-height: 60px;
transition: all 0.3s ease-out;
}
.button:hover .icon i {
color: var(--color-white);
}
.button:nth-child(1):hover .icon {
background-color: var(--color-blue-dark);
}
.button:nth-child(2):hover .icon {
background-color: var(--color-blue);
}
.button:nth-child(3):hover .icon {
background-color: var(--color-magenta);
}
.button:nth-child(4):hover .icon {
background-color: var(--color-red);
}
.button span {
font-size: 20px;
font-weight: bold;
margin-left: 10px;
}
.button:nth-child(1) span {
color: var(--color-blue-dark);
}
.button:nth-child(2) span {
color: var(--color-blue);
}
.button:nth-child(3) span {
color: var(--color-magenta);
}
.button:nth-child(4) span {
color: var(--color-red);
}
</style>
<div class="wrapper">
<div class="button">
<div class="icon">
<i class="fab fa-facebook-f"></i>
</div>
<span>Facebook</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-twitter"></i>
</div>
<span>Twitter</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-instagram"></i>
</div>
<span>Instagram</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-youtube"></i>
</div>
<span>Youtube</span>
</div>
</div>
Change the value of your border-radius on .button:hover
:root {
--color-orange: #ff6600;
--color-green: #22d122;
--color-cyan: #33ffff;
--color-magenta: #f33192;
--color-white: #ffffff;
--color-blue: #166fd4;
--color-magenta-dark: #831a4e;
--color-gray: #d6d6d6;
--color-red: #ff0000;
--color-graydark: #333;
--color-blue-dark: #103d68;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: "Nunito", sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: repeat(4, auto);
place-content: center;
width: 100%;
height: 100vh;
background-color: var(--color-gray);
}
.button {
display: inline-block;
background-color: var(--color-white);
width: 60px;
height: 60px;
overflow: hidden;
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-out;
border-radius: 50%;
margin: 0 5px;
cursor: pointer;
}
.button:hover {
width: 200px;
border-radius: 50px;
}
.button .icon {
display: inline-block;
text-align: center;
font-size: 20px;
border-radius: 50%;
height: 60px;
width: 60px;
line-height: 60px;
transition: all 0.3s ease-out;
}
.button:hover .icon i {
color: var(--color-white);
}
.button:nth-child(1):hover .icon {
background-color: var(--color-blue-dark);
}
.button:nth-child(2):hover .icon {
background-color: var(--color-blue);
}
.button:nth-child(3):hover .icon {
background-color: var(--color-magenta);
}
.button:nth-child(4):hover .icon {
background-color: var(--color-red);
}
.button span {
font-size: 20px;
font-weight: bold;
margin-left: 10px;
}
.button:nth-child(1) span {
color: var(--color-blue-dark);
}
.button:nth-child(2) span {
color: var(--color-blue);
}
.button:nth-child(3) span {
color: var(--color-magenta);
}
.button:nth-child(4) span {
color: var(--color-red);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css">
<div class="wrapper">
<div class="button">
<div class="icon">
<i class="fab fa-facebook-f"></i>
</div>
<span>Facebook</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-twitter"></i>
</div>
<span>Twitter</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-instagram"></i>
</div>
<span>Instagram</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-youtube"></i>
</div>
<span>Youtube</span>
</div>
</div>
You also need to change height on hover.
.button:hover {
width: 200px;
height: 200px;
border-radius: 50px;
}
But I recommend you to use transform: scale(2) if you aiming for performance.
when you hover the button its height increases and the width
.button:hover{
transform:scale(1.015deg)
}
I need a vertical navbar that will change the icon to text on hover. But for some reason I can't align the icon and text vertically in the center inside the 'a' tag.
Can someone help?
.sidebar{
background-color: #555;
position: fixed;
height: 100%;
width: 100px;
top: 0;
left: 0;
}
.sidebar a{
text-align: center;
display: block;
padding: 20px;
height: 90px;
color: #fff
}
.sidebar a i{
font-size: 24px;
}
.sidebar a b{
font-size: 18px;
display: none;
}
.sidebar a b:hover{
display: block;
}
.sidebar a i:hover{
display: none;
}
<link href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" rel="stylesheet"/>
<header>
<div class="sidebar">
<i class="fas fa-home"></i><b>Home</b>
<i class="fas fa-home"></i><b>About</b>
<i class="fas fa-home"></i><b>Skills</b>
<i class="fas fa-home"></i><b>Works</b>
</div>
</header>
Is that what are you looking for?
If you want to rotate text you can also add
writing-mode: vertical-rl;
.sidebar{
background-color: #555;
position: fixed;
height: 100%;
width: 100px;
top: 0;
left: 0;
}
.sidebar a{
text-align: center;
display: block;
padding: 20px;
height: 90px;
color: #fff
}
.sidebar a i{
font-size: 24px;
}
.sidebar a b{
font-size: 18px;
display: none;
}
.sidebar a:hover b{
display: block;
}
.sidebar a:hover i{
display: none;
}
<link href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" rel="stylesheet"/>
<header>
<div class="sidebar">
<i class="fas fa-home"></i><b>Home</b>
<i class="fas fa-home"></i><b>About</b>
<i class="fas fa-home"></i><b>Skills</b>
<i class="fas fa-home"></i><b>Works</b>
</div>
</header>
I've cancelled padding on sidebar a and added flexbox. Also fixed hovers, I hope it would fix your problem.
.sidebar{
background-color: #555;
position: fixed;
height: 100%;
width: 100px;
top: 0;
left: 0;
}
.sidebar a{
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
height: 90px;
color: #fff
}
.sidebar a i{
font-size: 24px;
}
.sidebar a b{
color: white;
font-size: 18px;
display: none;
}
.sidebar a:hover b{
display: flex;
}
.sidebar a:hover i{
display: none;
}
<link href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" rel="stylesheet"/>
<header>
<div class="sidebar">
<i class="fas fa-home"></i><b>Home</b>
<i class="fas fa-home"></i><b>About</b>
<i class="fas fa-home"></i><b>Skills</b>
<i class="fas fa-home"></i><b>Works</b>
</div>
</header>
This question already has answers here:
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
Closed 2 years ago.
I am trying to have a logo on the left of the div and the nav on the right side of the div, but I can't seem to get the nav to move to the right.
.full {
background-color: black;
color: white;
width: 300px;
height: 400px;
border-radius: 20px;
transition: 1s ease;
}
.autofill {
padding: 10px;
}
.topbar {
overflow: hidden;
width: 100%;
height: 50px;
background-color: #131218;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
display: flex;
align-items: center;
}
.body {
display: block;
width: 100%;
height: 330px;
background-color: blue;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
}
img {
height: 50px;
padding: 5px;
border-radius: 200px;
float: left;
will-change: transform;
animation: logofloat 1s ease-in-out infinite alternate;
}
#keyframes logofloat {
from {
transform: translateY(5px);
}
to {
transform: translateY(15px);
}
}
a {
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
align-items: center;
float: left;
display: block;
margin-right: 10px;
background-color: #25242B;
text-align: center;
text-decoration: none;
border-radius: 5px;
}
i {
padding: 5px;
color: #4D4A58;
}
a:hover:not(.active) {
background-color: grey;
}
a:not(.active) {
color: white;
}
.active {
background-image: linear-gradient(to right, #5433FF, #20BDFF, #6FB1FC);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="full">
<div class="autofill" id="background">
<div class="topbar">
<img class="logo" src="/icons/glacier.png">
<div class="nav">
<i class="fa fa-fw fa-align-justify"></i>
<i class="fa fa-fw fa-wifi"></i>
<i class="fa fa-fw fa-user"></i>
<a class="active" href="#"><i class="fa fa-fw fa-gear"></i></a>
</div>
</div>
<div class="body"></div>
</div>
Here is my fiddle for the project: https://jsfiddle.net/70wzxsL5/
How can I fix the aligning of the logo and nav in the division?
Add this justify-content: space-between; on .topbar
.topbar {
overflow: hidden;
width: 100%;
height: 50px;
background-color: #131218;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
display: flex;
align-items: center;
justify-content: space-between;
}
https://jsfiddle.net/lalji1051/fv1ju8cw/2/
Add justify-content: space-between; to .topbar:
.full {
background-color: black;
color: white;
width: 300px;
height: 400px;
border-radius: 20px;
transition: 1s ease;
}
.autofill {
padding: 10px;
}
.topbar {
overflow: hidden;
width: 100%;
height: 50px;
background-color: #131218;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
display: flex;
align-items: center;
justify-content: space-between; /* Here */
}
.body {
display: block;
width: 100%;
height: 330px;
background-color: blue;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
}
img {
height: 50px;
padding: 5px;
border-radius: 200px;
float: left;
will-change: transform;
animation: logofloat 1s ease-in-out infinite alternate;
}
#keyframes logofloat {
from {
transform: translateY(5px);
}
to {
transform: translateY(15px);
}
}
a {
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
align-items: center;
float: left;
display: block;
margin-right: 10px;
background-color: #25242B;
text-align: center;
text-decoration: none;
border-radius: 5px;
}
i {
padding: 5px;
color: #4D4A58;
}
a:hover:not(.active) {
background-color: grey;
}
a:not(.active) {
color: white;
}
.active {
background-image: linear-gradient(to right, #5433FF, #20BDFF, #6FB1FC);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="full">
<div class="autofill" id="background">
<div class="topbar">
<img class="logo" src="/icons/glacier.png">
<div class="nav">
<i class="fa fa-fw fa-align-justify"></i>
<i class="fa fa-fw fa-wifi"></i>
<i class="fa fa-fw fa-user"></i>
<a class="active" href="#"><i class="fa fa-fw fa-gear"></i></a>
</div>
</div>
<div class="body"></div>
</div>
I have a navigation bar that will expand when the mouse is over it. I wish to display heading text once it is expanded (currently shows icons), I have used display: none on the heading tag, which then toggles to display: inline-block when the :hover event is active on the navbar. However, upon expansion of the navbar the text renders in on two lines before positioning itself into one which I want. I want to get rid of this and have the text render in as one line only while the navbar expands. My code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Navigation Bar</title>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<script
src="https://kit.fontawesome.com/6cc49d804e.js"
crossorigin="anonymous"
></script>
</head>
<body>
<div id="sidenav">
<div id="sidenav-brand">
<div id="sidenav-heading">
<h2>Expanded Test</h2>
</div>
<div id="sidenav-expand">
<i id="expand-icon" class="fas fa-angle-double-right fa-2x"></i>
</div>
</div>
<div id="sidenav-links">
<ul id="links">
<li>
<i class="fas fa-fw fa-id-card fa-2x"></i>
</li>
<li>
<i class="fas fa-fw fa-graduation-cap fa-2x"></i>
</li>
<li>
<i class="fas fa-fw fa-briefcase fa-2x"></i>
</li>
<li>
<i class="fas fa-fw fa-smile-beam fa-2x"></i>
</li>
</ul>
</div>
</div>
</body>
</html>
body {
}
/* Make the width full-size then use javascript to minimise so content fits */
#sidenav {
height: 100%;
width: 75px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #1e1e2d;
overflow-x: hidden;
color: grey;
transition: width 0.5s;
}
#sidenav-brand {
padding: 25px 20px;
background-color: #1a1a27;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
#sidenav-heading {
display: none;
}
#sidenav-heading h2 {
margin: 0;
color: white;
}
#sidenav-expand {
text-align: center;
margin-left: 3px;
}
#expand-icon {
transition: transform 0.5s;
}
#sidenav:hover {
width: 280px;
}
#sidenav:hover #expand-icon {
transform: rotate(180deg);
}
#sidenav:hover #sidenav-heading {
display: inline-block;
}
#sidenav-links {
margin: 15px 0;
}
#links {
list-style-type: none;
padding: 0;
text-align: left;
}
#links li {
padding: 18px;
display: block;
}
#links li:hover {
color: white;
background-color: hotpink;
}
.fas {
vertical-align: middle;
}
Please check this fiddle for what I mean when the navbar expands:
https://jsfiddle.net/4pk25oLh/
P.S. The effect I want is the same as when you get rid of the space in the heading text (however, I will need the space). Any help would be greatly appreciated.
Instead of using display property, you can create a cool fade animation for that.
First, add white-space: nowrap to the <h2>, so the text will not wrap.
Then, you use properties such as visiblity, opacity, max-width and transition to create the effect.
body {
}
/* Make the width full-size then use javascript to minimise so content fits */
#sidenav {
height: 100%;
width: 75px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #1e1e2d;
overflow-x: hidden;
color: grey;
transition: width 0.5s;
}
#sidenav-brand {
padding: 25px 20px;
background-color: #1a1a27;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
#sidenav-heading {
display: inline-block;
}
#sidenav-heading h2 {
margin: 0;
color: white;
white-space: nowrap;
opacity: 0;
max-width: 0;
transition: 0.16s;
visibility: hidden;
}
#sidenav-expand {
text-align: center;
margin-left: 3px;
}
#expand-icon {
transition: transform 0.5s;
}
#sidenav:hover {
width: 280px;
}
#sidenav:hover #expand-icon {
transform: rotate(180deg);
}
#sidenav:hover #sidenav-heading h2 {
opacity: 1;
max-width: 100vw;
visibility: visible;
transition: 0.4s 0.5s;
}
#sidenav-links {
margin: 15px 0;
}
#links {
list-style-type: none;
padding: 0;
text-align: left;
}
#links li {
padding: 18px;
display: block;
}
#links li:hover {
color: white;
background-color: hotpink;
}
.fas {
vertical-align: middle;
}
I think white-space: nowrap; might help.
#sidenav-heading h2 {
margin: 0;
color: white;
white-space: nowrap;
}
Please update below CSS selectors in your style file or CSS:
body {
}
/* Make the width full-size then use javascript to minimise so content fits */
#sidenav {
height: 100%;
width: 75px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #1e1e2d;
overflow-x: hidden;
color: grey;
transition: width 0.5s;
}
#sidenav-brand {
padding: 25px 20px;
background-color: #1a1a27;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
#sidenav-heading {
display: inline-block;
position: absolute;
width: 240px;
left: 20px;
transition: opacity 0.3s;
-webkit-transition: opacity 0.3s;
opacity: 0;
}
#sidenav-heading h2 {
margin: 0;
color: white;
}
#sidenav-expand {
text-align: center;
margin-left: 3px;
}
#expand-icon {
transition: transform 0.5s;
}
#sidenav:hover {
width: 280px;
}
#sidenav:hover #expand-icon {
transform: rotate(180deg);
}
#sidenav:hover #sidenav-heading {
opacity: 1;
}
#sidenav-links {
margin: 15px 0;
}
#links {
list-style-type: none;
padding: 0;
text-align: left;
}
#links li {
padding: 18px;
display: block;
}
#links li:hover {
color: white;
background-color: hotpink;
}
.fas {
vertical-align: middle;
}
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<script
src="https://kit.fontawesome.com/6cc49d804e.js"
crossorigin="anonymous"
></script>
<div id="sidenav">
<div id="sidenav-brand">
<div id="sidenav-heading">
<h2>Expanded Test</h2>
</div>
<div id="sidenav-expand">
<i id="expand-icon" class="fas fa-angle-double-right fa-2x"></i>
</div>
</div>
<div id="sidenav-links">
<ul id="links">
<li>
<i class="fas fa-fw fa-id-card fa-2x"></i>
</li>
<li>
<i class="fas fa-fw fa-graduation-cap fa-2x"></i>
</li>
<li>
<i class="fas fa-fw fa-briefcase fa-2x"></i>
</li>
<li>
<i class="fas fa-fw fa-smile-beam fa-2x"></i>
</li>
</ul>
</div>
</div>
There are two divs with an image and hyperlink in each. The goal is to force each div to be an entire hyperlink - without jQuery, JavaScript or Onclick function.
What do I have now:
.near {
display: flex;
align-items: stretch;
justify-content: space-between;
}
.previous,
.next {
width: 50%;
padding: 20px 30px;
font-size: 1em;
font-style: italic;
font-weight: 400;
cursor: pointer;
align-items: center;
display: flex;
text-align: center;
border-radius: 8px;
background: #fff;
box-shadow: 0 0 1px #5C3317;
}
.previous:hover,
.next:hover {
box-shadow: 0 0 10px #5C3317;
background: lightgreen;
}
.previous a,
.next a {
color: #000;
}
.previous i {
float: left;
padding-right: .7em;
align-self: center;
}
.next i {
float: right;
padding-left: .7em;
align-self: center;
}
.text {
width: 100%;
}
<script src="https://use.fontawesome.com/d91d412715.js"></script>
<div class="near">
<div class="previous">
<i class="fa fa-hand-spock-o fa-3x" aria-hidden="true"></i>
<div class="text">
Hello
</div>
</div>
<div class="next">
<div class="text">
Bye-bye
</div>
<i class="fa fa-bicycle fa-3x" aria-hidden="true"></i>
</div>
</div>
How can I reach this?
You can see the changes I've made as they are the CSS rules indented to the left. In short you need to make the font awesome icons absolutely positioned so the link element can take up the whole box area.
.near {
display: flex;
align-items: stretch;
justify-content: space-between;
}
.previous,
.next {
width: 50%;
padding: 0;
font-size: 1em;
font-style: italic;
font-weight: 400;
cursor: pointer;
align-items: center;
display: flex;
text-align: center;
border-radius: 8px;
background: #fff;
box-shadow: 0 0 1px #5C3317;
}
.previous:hover,
.next:hover {
box-shadow: 0 0 10px #5C3317;
background: lightgreen;
}
.previous a,
.next a {
color: #000;
display: block;
padding: 40px 60px;
}
.previous i {
float: left;
padding-right: .7em;
align-self: center;
position: absolute;
top: 35px;
left: 35px;
}
.next i {
float: right;
padding-left: .7em;
align-self: center;
position: absolute;
top: 35px;
right: 35px;
}
.text {
width: 100%;
z-index: 2;
}
<script src="https://use.fontawesome.com/d91d412715.js"></script>
<div class="near">
<div class="previous">
<i class="fa fa-hand-spock-o fa-3x" aria-hidden="true"></i>
<div class="text">
Hello
</div>
</div>
<div class="next">
<div class="text">
Bye-bye
</div>
<i class="fa fa-bicycle fa-3x" aria-hidden="true"></i>
</div>
</div>