https://codepen.io/anon/pen/NpoevM
http://imgur.com/a/OQ3cu
I want to have the small lines to separate the boxes. I was thinking about how to make the lines like in the picture. I was thinking using borders or span but having trouble
#third {
height: 55%;
width: 40%;
display: flex;
flex-direction: column;
float: right;
}
.t-row {
height: 100%;
display: flex;
}
.tbox {
width: 50%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.fa {
font-size: 5em !important;
}
<section id="third">
<div class="hr-lines">
<hr class="icon-sep">
</div>
<div class="t-row">
<div class="tbox tb-one">
<i class="fa fa-home" aria-hidden="true"></i>
<h1 class="t-text">Home</h1>
</div>
<div class="tbox tb-two">
<i class="fa fa-info-circle" aria-hidden="true"></i>
<h1 class="t-text">About</h1>
</div>
</div>
<div class="t-row">
<div class="tbox tb-three">
<i class="fa fa-book" aria-hidden="true"></i>
<h1 class="t-text">Work</h1>
</div>
<div class="tbox tb-four">
<i class="fa fa-envelope" aria-hidden="true"></i>
<h1 class="t-text">Hire</h1>
</div>
</div>
</section>
check below snippet. I have used :after for all four div and used border to create the + sign.
#third {
height: 55%;
width: 40%;
display: flex;
flex-direction: column;
float: right;
}
.t-row {
height: 100%;
display: flex;
}
.tbox {
width: 50%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.fa {
font-size: 5em !important;
}
.tb-one,
.tb-two,
.tb-three,
.tb-four {
position: relative;
}
.tb-one:after,
.tb-two:after,
.tb-three:after,
.tb-four:after {
position: absolute;
content: " ";
border: 1px solid #000;
width: 20px;
height: 20px;
display: block;
}
.tb-one:after {
bottom: 0;
right: 0;
border-top: none;
border-left: none
}
.tb-two:after {
bottom: 0;
left: 0;
border-top: none;
border-right: none
}
.tb-three:after {
top: 0;
right: 0;
border-bottom: none;
border-left: none
}
.tb-four:after {
top: 0;
left: 0;
border-bottom: none;
border-right: none
}
<section id="third">
<div class="hr-lines">
<hr class="icon-sep">
</div>
<div class="t-row">
<div class="tbox tb-one">
<i class="fa fa-home" aria-hidden="true"></i>
<h1 class="t-text">Home</h1>
</div>
<div class="tbox tb-two">
<i class="fa fa-info-circle" aria-hidden="true"></i>
<h1 class="t-text">About</h1>
</div>
</div>
<div class="t-row">
<div class="tbox tb-three">
<i class="fa fa-book" aria-hidden="true"></i>
<h1 class="t-text">Work</h1>
</div>
<div class="tbox tb-four">
<i class="fa fa-envelope" aria-hidden="true"></i>
<h1 class="t-text">Hire</h1>
</div>
</div>
</section>
In your code add four classes with border property of div.
<style>
#third {
height: 55%;
width: 40%;
display: flex;
flex-direction: column;
float: right;
}
.t-row {
height: 100%;
display: flex;
}
.tbox {
width: 50%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.fa {
font-size: 5em !important;
}
.left-border{ border-left : 1px solid;}
.right-border{ border-right : 1px solid;}
.bottom-border{ border-bottom : 1px solid;}
.top-border{ border-top: 1px solid;}
</style>
<section id="third">
<div class="hr-lines">
<hr class="icon-sep">
</div>
<div class="t-row">
<div class="tbox tb-one right-border bottom-border">
<i class="fa fa-home" aria-hidden="true"></i>
<h1 class="t-text">Home</h1>
</div>
<div class="tbox tb-two left-border bottom-border">
<i class="fa fa-info-circle" aria-hidden="true"></i>
<h1 class="t-text">About</h1>
</div>
</div>
<div class="t-row">
<div class="tbox tb-three top-border right-border">
<i class="fa fa-book" aria-hidden="true"></i>
<h1 class="t-text">Work</h1>
</div>
<div class="tbox tb-four top-border left-border">
<i class="fa fa-envelope" aria-hidden="true"></i>
<h1 class="t-text">Hire</h1>
</div>
</div>
</section>
You can use a '+' inside a span and position / style it
#third {
height: 55%;
width: 40%;
display: flex;
flex-direction: column;
float: right;
position:relative;
}
.t-row {
height: 100%;
display: flex;
}
.tbox {
width: 50%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.fa {
font-size: 5em !important;
}
.lines { position:absolute; font-size:150px; top:17%; left:40% }
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
<section id="third">
<span class="lines">+</span>
<div class="t-row">
<div class="tbox tb-one">
<i class="fa fa-home" aria-hidden="true"></i>
<h1 class="t-text">Home</h1>
</div>
<div class="tbox tb-two">
<i class="fa fa-info-circle" aria-hidden="true"></i>
<h1 class="t-text">About</h1>
</div>
</div>
<div class="t-row">
<div class="tbox tb-three">
<i class="fa fa-book" aria-hidden="true"></i>
<h1 class="t-text">Work</h1>
</div>
<div class="tbox tb-four">
<i class="fa fa-envelope" aria-hidden="true"></i>
<h1 class="t-text">Hire</h1>
</div>
</div>
</section>
Related
I'm trying to use flexbox to create a responsive layout of a product list page but this code leaves a lot of whitespace to the right of the page, ive tried using justify-content:space-between but that did not work as well. Adding overflow:hidden to .container class did nothing as well.
edit:someone said it works fine on their end but this is how
my screen looks
*{
margin:0;
padding: 0;
box-sizing: border-box;
text-transform: capitalize;
text-decoration: none;
transition: all .2s linear;
}
body{
overflow-x: hidden;
}
.container{
min-height: 100vh;
display:flex;
flex-direction: row;
justify-content:center;
flex-wrap: wrap;
padding: 40px 0;
}
.card{
height:500px;
width:280px ;
overflow: hidden;
position: relative;
align-self: center;
margin: 40px;
}
.card img{
width: 100%;
height: 80%;
object-fit: cover;
}
.card .info
{
text-align: center;
line-height: 25px;
}
.card .info .stars i
{
color: gold;
padding: 10px 0;
}
.card .info .price{
font-size: 20px;
color:#f00333;
letter-spacing: 1px;
}
.card .info h3{
color: #333;
padding-top: 5px;
}
.card .discount
{
position: absolute;
top:15px;
left:15px;
height:50px;
width:50px;
display: grid;
background-color: rgba(255, 0, 0, 0.6);
color:#fff;
font-weight: bold;
border-radius: 50%;
text-align: center;
line-height: 50px;
}
.card .panel
{
position: absolute;
top:15px;
right: -50%;
width: 45px;
background: rgba(255, 255, 255, 0.644);
display: flex;
align-items: center;
flex-flow: column;
}
.card:hover .panel{
right: 15px;
opacity: 1;
}
.card button
{
position: absolute;
left:50%;
bottom: 0%;
height: 40px;
width: 140px;
border: none;
outline:none;
background: rgba(0,0,0,0.6);
color:#fff;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transform: translateX(-50%);
opacity: 0;
transition-delay: .2s;
}
.card:hover button{
opacity: 1;
bottom: 25%;
}
.card button:hover{
background: (255,0,0,0.6);
}
.card .panel a{
font-size: 20px;
color: #333;
margin: 15px 0;
}
.card .panel a:hover{
color: rgba(255,0,0,0.9);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<div class="container">
<div class="card">
<img src="assets/women1.jpeg" alt="">
<span class="discount">-20%</span>
<div class="panel">
</div>
<button>add to cart</button>
<div class="info">
<h3>women's clothing</h3>
<div class="stars">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half"></i>
</div>
<strong class="price">$100/-</strong>
</div>
</div>
<div class="card">
<img src="assets/women1.jpeg" alt="">
<span class="discount">-20%</span>
<div class="panel">
</div>
<button>add to cart</button>
<div class="info">
<h3>women's clothing</h3>
<div class="stars">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half"></i>
</div>
<strong class="price">$100/-</strong>
</div>
</div>
<div class="card">
<img src="assets/women1.jpeg" alt="">
<span class="discount">-20%</span>
<div class="panel">
</div>
<button>add to cart</button>
<div class="info">
<h3>women's clothing</h3>
<div class="stars">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half"></i>
</div>
<strong class="price">$100/-</strong>
</div>
</div>
</div>
It Works Fine.
In Your Browser do a hard refresh.
I hope it will do the job done.
Hard Refresh : Ctrl + F5
Click here. It are some docs on hard Refresh If you want to know more.
Or If Nothing Works use position : absolute or Bootstrap.
I am completely new to website designing and have been trying to make a e commerce website from scratch,
here in my website's products page the footer doesn't span the whole width. can somebody help me with this. The css and html are divided by a line of asterisks im actually new to stack overflow
i've tried searching in w3 schools and many youtube tutorials but all effort is in vain.
please guide me.
thanks in advance (^-^)
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grocery guys</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="header">
<div class="container">
<div class="navbar">
<div class="logo">
<img src="logo.png" width="125px">
</div>
<nav>
<ul id="Menuitems">
<li>Home </li>
<li>Products </li>
<li>About </li>
<li>Contact </li>
<li>Account </li>
</ul>
</nav>
<img src="cart.png" width="30px" height="30px">
<img src="menu.png" class="menu-icon" onclick="menutoggle()" >
</div>
</div>
</div>
<!--------featured products-------->
<div class="small-container">
<h2 class="title">Featured products</h2>
<div class="row">
<div class="col-4">
<img src="product-1.jpg" alt="">
<h4>Curology moisturiser </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-2.jpg" alt="">
<h4>Beemster cheese wheel </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-3.jpg" alt="">
<h4>Aqua panna </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-4.jpg" alt="">
<h4>Orignal's beer light </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
</div>
<!------footer----->
<div class="footer">
<div class="container">
<div class="row">
<div class="footer-col-1">
<h3>Reach us at Whatsapp <span>©</span</h3>
</div>
<div class="footer-col-2">
<img src="logo-white.png" alt="">
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Quasi, eos.</p>
</div>
<div class="footer-col-3">
<h3>Useful links</h3>
<ul>
<li>Coupons</li>
<li>Blog post</li>
<li>Return policy</li>
<li>Affiliate</li>
</ul>
</div>
<div class="footer-col-3">
<h3>Follow us</h3>
<ul>
<li>Whatsapp</li>
<li>Maps</li>
<li>Business card</li>
<li>Contact</li>
</ul>
</div>
</div>
<hr>
<p class="Copyright">Copyright 2021 <span>©</span> - Haneesh kenny - <i>made with love and a wierd sense of humour.</i></p>
</div>
</div>
<!--js for toggle menu-->
<script>
var Menuitems = document.getElementById("Menuitems")
Menuitems.style.maxHeight = "0px";
function menutoggle(){
if(Menuitems.style.maxHeight == "0px")
{
Menuitems.style.maxHeight = "200px";
}
else
{
Menuitems.style.maxHeight = "0px"
}
}
</script>
</body>
</html>
CSS
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
font-family: 'Poppins', sans-serif;
}
.navbar{
display: flex;
align-items: center;
padding: 20px;
}
nav{
flex: 1;
text-align: right;
}
nav ul{
display: inline-block;
list-style-type: none;
}
nav ul li{
display: inline-block;
margin-right: 20px;
}
a{
text-decoration: none
cornflowerblue
}
p{
color: cornflowerblue;
}
.container{
max-width: 1300px;
margin: auto;
padding-left: 25px;
padding-right: 25px;
}
.row{
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: space-around;
}
.col-2{
flex-basis: 50%;
min-width: 300px;
}
.col-2 img{
max-width: 100%;
padding: 50px 0;
}
.col-2 h1{
font-size: 50px;
line-height: 60px;
margin: 25px 0;
}
.btn{
display: inline-block;
background: #ff523b;
color: #fff;
padding: 8px 30px;
margin: 30px 0;
border-radius: 30px;
transition: background 0.5s;
}
.header{
background: radial-gradient(#fff,#e4ffd3);
}
.header .row{
margin-top: 70px;
}
.btn:hover{
background: #563434;
}
.categories{
margin: 70px 0;
}
.col-3{
flex-basis: 30%;
min-width: 250px;
margin-bottom: 30px;
}
.col-3 img{
width: 100%;
}
.small-container{
max-width: 1080px;
margin: auto;
padding-left: 25px;
padding-right: 25px;
}
.col-4{
flex-basis: 25%;
padding: 30px;
min-width: 200px;
margin-bottom: 50px;
transition: transform 0.5s;
}
.col-4 img{
width: 100%;
}
.title{
text-align: center;
margin: 0 auto 80px;
position: relative;
line-height: 60px;
color: #555;
}
.title::after{
content: '';
background: #00ff22;
width: 80px;
height: 5px;
border-radius: 5px;
position: absolute;
bottom: 0;
left: 46%;
transition: translateX(-50%);
}
.h4{
color: #555;
font-weight: normal;
}
.col-4 p{
font-size: 14px;
}
.rating .fa{
color: #ff523b;
}
.col-4:hover{
transform: translateY(-10px);
box-shadow: 8px 6px 34px grey;
}
/*-----offer------*/
.offer{
background: radial-gradient(#fff,#e4ffd3);
margin-top: 90px;
padding: 30px 0;
}
.col-2 .offer-img{
padding: 50px;
transform: translateX(-100px);
}
.small{
color: #555;
}
/*------Testimonial------*/
.testimonial{
padding-top: 100px;
}
.testimonial .col-3{
text-align: center;
padding: 40px 20px;
box-shadow: 0 0 30px 0px rgba(0,0,0,0.1);
cursor: pointer;
transition: transform 0.5;
}
.testimonial .col-3 img{
width: 50px;
margin-top: 20px;
border-radius: 50%;
}
.testimonial .col-3:hover{
transform: translateY(-10px);
}
.fa .fa-quote-left{
font-size: 34px;
color: #ff523b;
}
.col-3 p{
font-size: 12px;
margin: 12px 0;
color: #777;
}
.testimonial .col-3 h3{
font-weight: 600;
color: #555;
font-size: 16px;
}
/*----brands----*/
.brands{
margin: 100px auto;
}
.col-5{
width: 160px;
}
.col-5 img{
width: 100%;
cursor: pointer;
filter: grayscale(100%);
}
.col-5 img:hover{
filter: grayscale(0);
}
/*-----footer----*/
.footer{
background: #000;
color: #8a8a8a;
font-size: 14px;
padding: 60px 0 20px ;
}
.footer p{
color: #8a8a8a;
}
.footer h3{
color: white;
margin-bottom: 20px;
}
.footer-col-1, .footer-col-2, .footer-col-3, .footer-col-4{
min-width: 250px;
margin-bottom: 20px;
}
.footer-col-1{
flex-basis: 30%;
}
.footer-col-2{
flex: 1;
text-align: center;
}
.footer-col-2 img{
width: 180px;
margin-bottom: 20px;
}
.footer-col-3, .footer-col-4{
flex-basis: 12%;
text-align: center;
}
ul{
list-style: none;
}
.Copyright{
text-align: center;
}
.menu-icon{
width: 28px;
margin-left: 20px;
display: none;
}
/*------media query for menu--------*/
#media only screen and (max-width: 800px){
nav ul{
position: absolute;
top: 70px;
left: 0;
background: #333;
width: 100%;
overflow: hidden;
transition: max-height 0.5s;
}
nav ul li{
display: block;
margin-right: 50px;
margin-top: 10px;
margin-bottom: 10px;
}
nav ul li a{
color: white;
}
.menu-icon{
display: block;
cursor: pointer;
}
}
/*media query for less than 600 px*/
#media only screen and (max-width: 600px){
.row{
text-align: center;
}
.col-2, .col-3, .col-4{
flex-basis: 100%;
}
}
do this change
.small-container{
width: 100%;
margin: auto;
}
.row{
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: space-around;
max-width: 90vw;
}
make a div before the class row like this
<div style="width: 100%; display: flex;justify-content: center;
align-items: center;">
<div class="row">
<div class="col-4">
<img src="product-1.jpg" alt="">
<h4>Curology moisturiser </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-2.jpg" alt="">
<h4>Beemster cheese wheel </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-3.jpg" alt="">
<h4>Aqua panna </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-4.jpg" alt="">
<h4>Orignal's beer light </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
</div>
</div>
i have advice for u dont use max width
.row{
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: space-around;
max-width: 90vw;
}
.small-container{
width: 100%;
margin: auto;
}
add div befroe class row and enclude this css
<div style="width: 100%; display: flex;justify-content: center;
align-items: center;">
<div class="row">
<div class="col-4">
<img src="product-1.jpg" alt="">
<h4>Curology moisturiser </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-2.jpg" alt="">
<h4>Beemster cheese wheel </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-3.jpg" alt="">
<h4>Aqua panna </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
</div>
<p>$50.00</p>
</div>
<div class="col-4">
<img src="product-4.jpg" alt="">
<h4>Orignal's beer light </h4>
<div class="rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o" "></i>
</div>
<p>$50.00</p>
</div>
</div>
</div>
You should first check your syntax!
e.g
<i class="fa fa-star-o" "></i>
<!-- should be -->
<i class="fa fa-star-o"></i>
or
<h3>Reach us at Whatsapp <span>©</span</h3>
<!-- should be -->
<h3>Reach us at Whatsapp <span>©</span></h3>
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>
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
Say I want to a container of courses that would look something like this
Is this bad making essentially each part of the "course" it's own flexbox?
.course-container {
display: flex;
flex-direction: column;
}
.course-options {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.course-title {
display: flex;
flex-direction: row;
justify-content: center;
}
.course-grade {
display: flex;
flex-direction: row;
justify-content: flex-end;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="course-container">
<div class="course">
<div class="course-options">
<i class='fa fa-pencil-square-o fa-lg' aria-hidden="true"></i>
<i class='fa fa-trash-o fa-lg' aria-hidden="true"></i>
</div>
<div class="course-title">
Course 1
</div>
<div class="course-grade">
Grade: 0.00%
</div>
</div>
<div class="course">
<div class="course-options">
<i class='fa fa-pencil-square-o fa-lg' aria-hidden="true"></i>
<i class='fa fa-trash-o fa-lg' aria-hidden="true"></i>
</div>
<div class="course-title">
Course 2
</div>
<div class="course-grade">
Grade: 0.00%
</div>
</div>
</div>
You don't need to define display: flex on each inner element, you can use align-self instead.
.course-container,
.course {
display: flex;
flex-direction: column;
}
.course {
width: 300px;
border: 1px solid black;
padding: 10px;
height: 100px;
margin: 5px;
justify-content: space-between;
}
.course-options {
display: flex;
justify-content: space-between;
}
.course-title {
align-self: center;
}
.course-grade {
align-self: flex-end;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="course-container">
<div class="course">
<div class="course-options">
<i class='fa fa-pencil-square-o fa-lg' aria-hidden="true"></i>
<i class='fa fa-trash-o fa-lg' aria-hidden="true"></i>
</div>
<div class="course-title">
Course 1
</div>
<div class="course-grade">
Grade: 0.00%
</div>
</div>
<div class="course">
<div class="course-options">
<i class='fa fa-pencil-square-o fa-lg' aria-hidden="true"></i>
<i class='fa fa-trash-o fa-lg' aria-hidden="true"></i>
</div>
<div class="course-title">
Course 2
</div>
<div class="course-grade">
Grade: 0.00%
</div>
</div>
</div>
There is nothing wrong with how you set it up, and whether it is the best is very much dependent on how a course box should behave.
With what I know now, you could optimize that code, which I would, and achieve the same result.
Here I removed all inner wrappers and used auto margins, which got an upgrade with Flexbox, that make it easy to align items within its parent.
The benefit with a structure like this, besides being having a lot less markup, you have endless ways to reorder the items based on content or screen sizes.
Stack snippet
.course-container {
display: flex;
flex-direction: column;
}
.course {
display: flex;
flex-wrap: wrap;
align-items: flex-start; /* align to top, and prevent from stretch */
width: 250px;
height: 120px;
margin: 5px;
border: 1px solid lightgray;
}
.course .fa-trash-o,
.course .grade {
margin-left: auto; /* push trash and grade to the right */
}
.course .grade {
margin-top: auto; /* push to bottom */
}
.course .title {
flex-basis: 100%; /* take full width, make it wrap on a row of its own */
margin: auto 0; /* center vertically */
text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="course-container">
<div class="course">
<i class='fa fa-pencil-square-o fa-lg' aria-hidden="true"></i>
<i class='fa fa-trash-o fa-lg' aria-hidden="true"></i>
<a class='title' href="">Course 1</a>
<a class='grade' href="">Grade: 0.00%</a>
</div>
<div class="course">
<i class='fa fa-pencil-square-o fa-lg' aria-hidden="true"></i>
<i class='fa fa-trash-o fa-lg' aria-hidden="true"></i>
<a class='title' href="">Course 2</a>
<a class='grade' href="">Grade: 0.00%</a>
</div>
</div>
This situation does NOT require flexbox. Flexbox still has less than 90% browser support worldwide (unprefixed), so I would not use it yet, unless you have absolutely no alternative.
This is a proper solution that works in all browsers:
.card {
text-align: center;
position: relative;
width: 100%;
max-width: 300px;
height: 100px;
line-height: 100px;
border: 1px solid black;
margin: 5px;
}
.card > * {line-height: 1.4em; position: absolute;}
.card > .edit {left: 0; top: 0;}
.card > .delete {right: 0; top: 0;}
.card > .grade {right: 0; bottom: 0;}
<div class="card">
edit
delete
<span class="grade">grade</span>
course 1
</div>
<div class="card">
edit
delete
<span class="grade">grade</span>
course 2
</div>