Links only to the parent div - html

I wanted to make a card (which has an image and text) clickable. I applied the link to the parent div only. See the link added to the first card. Then I added the code to the HTML widget in our tool. When I added it to the HTML widget, it applied that link to all the nested divs and the whole card was not clickable. Either the image or text was clickable instead of the whole card.
Here's the code in which I added the hyperlink to card 1. I am wondering why it is automatically adding the link to the parent div to all the div inside the parent div. Because of this, I am not able to make the whole card clickable.
.tcolumn {
float: left;
width: 18.68%;
margin-bottom: 16px;
padding: 0 8px;
}
#media screen and (max-width: 650px) {
.tcolumn {
width: 100%;
display: block;
}
}
.tcard {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
border: 2px solid #1e5b67;
}
.tcontainer {
padding: 0 16px;
text-align: center;
background: #ffffff;
margin-top: -25px;
}
.tcontainer::after,
.row::after {
content: "";
clear: both;
display: table;
}
.ttitle {
color: grey;
}
.tbutton {
border: none;
outline: 0;
display: inline-block;
padding: 8px;
color: white;
background-color: #000;
text-align: center;
cursor: pointer;
width: 100%;
}
<div class="row">
<div class="tcolumn">
<a style="display: inline-block;" href="https://picsum.photos/images">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 1</p>
</div>
</div>
</div>
</div>
</a>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="Mike" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 2</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 3</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 4</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 5</p>
</div>
</div>
</div>
</div>
</div>
<!-- Here's how the system changed my above code in the HTML Widget: -->
<div class="row">
<div class="tcolumn">
<a style="display:inline-block;" href="https://picsum.photos/images">
</a>
<div class="tcard">
<a style="display:inline-block;" href="https://picsum.photos/images"><img src="https://picsum.photos/id/1/222/148" alt="John" /></a>
<div class="tcontainer">
<a style="display:inline-block;" href="https://picsum.photos/images">
</a>
<div style="padding-top:30px;height:175px;font-family:Arial;">
<a style="display:inline-block;" href="https://picsum.photos/images">
</a>
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;"><a style="display:inline-block;" href="https://picsum.photos/images">Content 1</a></p>
<a style="display:inline-block;" href="https://picsum.photos/images">
</a>
</div>
<a style="display:inline-block;" href="https://picsum.photos/images">
</a>
</div>
<a style="display:inline-block;" href="https://picsum.photos/images">
</a>
</div>
<a style="display:inline-block;" href="https://picsum.photos/images">
</a>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="Mike" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 2</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 3</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 4</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 5</p>
</div>
</div>
</div>
</div>
</div>

You should move the closing anchor tag </a> before its previous </div>. It's a problem with the tags order.
.tcolumn {
float: left;
width: 18.68%;
margin-bottom: 16px;
padding: 0 8px;
}
#media screen and (max-width: 650px) {
.tcolumn {
width: 100%;
display: block;
}
}
.tcard {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
border: 2px solid #1e5b67;
}
.tcontainer {
padding: 0 16px;
text-align: center;
background: #ffffff;
margin-top: -25px;
}
.tcontainer::after,
.row::after {
content: "";
clear: both;
display: table;
}
.ttitle {
color: grey;
}
.tbutton {
border: none;
outline: 0;
display: inline-block;
padding: 8px;
color: white;
background-color: #000;
text-align: center;
cursor: pointer;
width: 100%;
}
<div class="row">
<div class="tcolumn">
<a style="display:inline-block;" href="https://picsum.photos/images">
<div class="tcard">
<img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 1</p>
</div>
</div>
</div>
</a>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="Mike" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 2</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 3</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 4</p>
</div>
</div>
</div>
</div>
<div class="tcolumn">
<div class="tcard"><img src="https://picsum.photos/id/1/222/148" alt="John" />
<div class="tcontainer">
<div style="padding-top:30px;height:175px;font-family:Arial;">
<p style="font-size:15px;font-weight:600;color:#1e5b67;margin-top:33%;">Content 5</p>
</div>
</div>
</div>
</div>
</div>

Related

How can I get this code to show fontawesome icons?

I am trying to create some service icon boxes next to the services that are provided. I have tried it in this method however it does not work. I think font-awesome icons could work with this code but I don't know much about font-awesome. The HTML and CSS have been included and you will see that the icons are not being shown.
<style>.y-us-section {
padding: 82px 0 82px;
}
.y-us-head {
text-align: center;
margin: 0 0 91px;
}
.y-us-title h2 {
color: #000;
font-size: 30px;
letter-spacing: 0;
line-height: 32px;
text-transform: uppercase;
margin-bottom: 6px;
}
.y-us-title>p {
color: #777777;
line-height: 22px;
}
.y-us-title-border {
background: #006600 none repeat scroll 0 0;
border-radius: 2px;
display: inline-block;
height: 3px;
position: relative;
width: 50px;
}
.service-3 .service-box {
margin-bottom: 18px;
}
.service-3 .service-box .iconset {
float: left;
text-align: center;
width: 25%;
}
.service-3 .service-box .iconset i {
color: #000;
font-size: 44px;
}
.service-3 .service-box .y-us-content {
float: left;
width: 75%;
}
service-3 .service-box .y-us-content h4 {
color: #3a3a3a;
font-size: 18px;
letter-spacing: 0;
line-height: 22px;
margin: 14px 0 12px;
text-transform: uppercase;
}
.service-3 .service-box .y-us-content p {
color: #777777;
font-size: 13px;
font-weight: 300;
line-height: 24px;
}
.icon {
color: #70AD4;
padding: 0px;
font-size: 40px;
border: 1px solid #70AD47;
border-radius: 100px;
color: #000000;
font-size: 28px;
height: 70px;
line-height: 70px;
text-align: center;
width: 70px;
}
<body>
<div class="y-us-section">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 col-sm-12 col-xs-12">
<div class="y-us-head">
<div class="y-us-title">
</div>
</div>
</div>
</div>
<div style="clear: both">
<h3 style="float: left">Quality Assurance</h3>
<h3 style="float: right">Regulatory Affairs</h3>
</div>
<hr />
<br>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-content">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Quality Management Representative system</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Iso 13485 Implementation</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Internal Audits</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Suppiler Audits</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>CE Marking Files</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>UKCA Marking</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>PRRC</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Biological Evaluation</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Clinical Evaluation</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>EU Authorised Representative</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="glyphicon glyphicon-cog icon"></span>
</div>
<div class="y-us-content">
<h4>UK Responsible Person</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You seem to have exactly the right idea but Glyphicons are nothing to do with Font-Awesome.
Ensure that this line is added to the <head> of your page.
<script src="https://kit.fontawesome.com/d38a9ab6aa.js" crossorigin="anonymous"></script>
Then you can insert any icon from this page....
https://fontawesome.com/v5.15/icons ... In the same way you added the Glyphicons.
To have a small footprint (fast loading time), you may specify only icons you require.
------ Setup ------
-- Create folder 'webfonts' with subfolder 'font-awesome'
-- Copy 4 Font Awesome files (see below) in subforlder 'font-awesome'
-- Create a new file 'fontloader.css' in folder 'webfonts'
[webfonts]
+-- [font-awesome]
| +-- fa-solid-900.svg
| +-- fa-solid-900.ttf
| +-- fa-solid-900.woff
| +-- fa-solid-900.woff2
+-- fontloader.css
-- Insert the following css into file 'fontloader.css'
/* Font Awesome 5 Free */
#font-face {
font-family: 'Font Awesome 5 Free';
font-style: normal;
font-weight: 400;
font-display: auto;
src: url("../webfonts/font-awesome/fa-solid-900.woff2") format("woff2"),
url("../webfonts/font-awesome/fa-solid-900.woff") format("woff"),
url("../webfonts/font-awesome/fa-solid-900.ttf") format("truetype"),
url("../webfonts/font-awesome/fa-solid-900.svg#fontawesome") format("svg");
}
.fas, .far, .fab, .fa {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
display: inline-block;
font-family: 'Font Awesome 5 Free';
font-weight: 400;
font-style: normal;
font-variant: normal;
font-size: 1em;
line-height: 1;
text-rendering: auto;
}
-- Link the css to your html:
<link rel="stylesheet" href="URL/TO/webfonts/fontloader.css">
------ For each icon ------
-- Use https://fontawesome.com/icons/ to search icons.
/* Example: an 'house' icon, search it */
/* then use the hex code in this way */
.fa-house-user:before {
content: "\e065"
}
-- Now you can insert the icon into the html
<i class="fas fa-house-user"></i>
I hope this solution will help you. The format is not nice, but I kept your HTML as you provided and made the icons to show up.
<style>.y-us-section {
padding: 82px 0 82px;
}
.y-us-head {
text-align: center;
margin: 0 0 91px;
}
.y-us-title h2 {
color: #000;
font-size: 30px;
letter-spacing: 0;
line-height: 32px;
text-transform: uppercase;
margin-bottom: 6px;
}
.y-us-title>p {
color: #777777;
line-height: 22px;
}
.y-us-title-border {
background: #006600 none repeat scroll 0 0;
border-radius: 2px;
display: inline-block;
height: 3px;
position: relative;
width: 50px;
}
.service-3 .service-box {
margin-bottom: 18px;
}
.service-3 .service-box .iconset {
float: left;
text-align: center;
width: 25%;
}
.service-3 .service-box .iconset i {
color: #000;
font-size: 44px;
}
.service-3 .service-box .y-us-content {
float: left;
width: 75%;
}
service-3 .service-box .y-us-content h4 {
color: #3a3a3a;
font-size: 18px;
letter-spacing: 0;
line-height: 22px;
margin: 14px 0 12px;
text-transform: uppercase;
}
.service-3 .service-box .y-us-content p {
color: #777777;
font-size: 13px;
font-weight: 300;
line-height: 24px;
}
.icon {
color: #70AD4;
padding: 0px;
font-size: 20px;
border-radius: 100px;
color: #000000;
font-size: 28px;
height: 20px;
line-height: 20px;
text-align: center;
width: 20px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<div class="y-us-section">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 col-sm-12 col-xs-12">
<div class="y-us-head">
<div class="y-us-title">
</div>
</div>
</div>
</div>
<div style="clear: both">
<h3 style="float: left">Quality Assurance</h3>
<h3 style="float: right">Regulatory Affairs</h3>
</div>
<hr />
<br>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-content">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Quality Management Representative system</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Iso 13485 Implementation</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Internal Audits</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Suppiler Audits</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>CE Marking Files</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>UKCA Marking</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>PRRC</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="why-choose-banner">
<img src="http://themeinnovation.com/demo2/html/build-up/img/home1/why-choose.jpg" alt="">
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="y-us-contentbox">
<div class="service-3">
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Biological Evaluation</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>Clinical Evaluation</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>EU Authorised Representative</h4>
<p></p>
</div>
</div>
</div>
<div class="service-box">
<div class="clearfix">
<div class="iconset">
<span class="fa fa-cog icon"></span>
</div>
<div class="y-us-content">
<h4>UK Responsible Person</h4>
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Overflow scroll not showing everything in div, some part of the left side is still hidden

I have a flex container containing 7 columns (Monday to Sunday), each with a min-width of 100px. I want users to scroll horizontally to see every column when the screen is smaller. I set the flex container to overflow: scroll. Yes, now the scrollbar appears, and I can scroll left and right. However, the smaller the screen is, the more part of the left side is still hidden, no matter how I scroll. The right side is fine.
Please see the code here:
https://codesandbox.io/s/busy-framework-ke4l0?file=/index.html
How can I fix this? Thanks in advance.
Your problem is the justify-content: center; in the .week-flex class. Because the browser then always centers the (.week-flex) container which leads to this unexpected behavior. If you want a scrollable, centered flex container you could use an extra container like this.
<div class="page-container">
<h1>課程專區</h1>
<div class="container">
<div class="week-flex">
<div class="day-flex">
<div class="day">Monday</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status open">即將開課</p>
</div>
</div>
<div class="day-flex">
<div class="day">Tuesday</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status">課程進行中</p>
</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status open">即將開課</p>
</div>
</div>
<div class="day-flex">
<div class="day">Wednesday</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status open">即將開課</p>
</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status open">即將開課</p>
</div>
</div>
<div class="day-flex">
<div class="day">Thursday</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status">課程進行中</p>
</div>
</div>
<div class="day-flex">
<div class="day">Friday</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status open">即將開課</p>
</div>
</div>
<div class="day-flex">
<div class="day">Saturday</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status open">即將開課</p>
</div>
</div>
<div class="day-flex">
<div class="day">Sunday</div>
<div class="course">
<h4 class="level">初階</h4>
<p class="topic">Lv. 1</p>
<p class="time">20:00-21:00</p>
<p class="status">課程進行中</p>
</div>
</div>
</div>
</div>
</div>
And the css.
.container {
display: flex;
width: 100%;
max-width: 100%;
overflow: auto;
}
.week-flex {
display: flex;
flex-direction: row;
column-gap: 10px;
margin: 0 auto;
}
.day-flex {
display: flex;
flex-direction: column;
row-gap: 10px;
min-width: 100px;
text-align: center;
}
.course {
width: 100%;
border: 1px solid black;
border-radius: 5px;
padding: 5px 0;
}
h4 {
margin: 0;
}
.status {
color: #125a12;
}
.status.open {
color: #941616;
}
Here is also a working codesandbox: https://codesandbox.io/s/gifted-albattani-e75bc

How to make an absolutely positioned element have the same size as another element

I have a layout like this:
body {
text-align: center;
}
.link {
position: relative;
}
.info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
background-color: #263238;
color: #1DE9B6;
opacity: 0;
visibility: hidden;
}
.link:hover .info {
opacity: 1;
visibility: visible;
}
.col-md-3 {
margin-bottom: 30px;
}
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
</div>
</div>
When the layout gets small, and only one column is displayed horizontally, the div which is supposed to show on hover gets as big as the column, but I only want it to be as big as the fluid image. How would I need to achieve this?
Here is the codepen link: https://codepen.io/Kestvir/pen/gKVwLe
Just add display: inline-block to the link element
.link {
position: relative;
display: inline-block;
}
Or you can also add d-inline-block position-relative classes on the .link elements .
body {
text-align: center;
}
.link {
position: relative;
display: inline-block;
}
.info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
background-color: #263238;
color: #1DE9B6;
opacity: 0;
visibility: hidden;
}
.link:hover .info {
opacity: 1;
visibility: visible;
}
.col-md-3 {
margin-bottom: 30px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
</div>
</div>

CSS table or grid

I want to create grid or table with three cards. Two cards in a row and the third under these two cards, like on the image (the third card can be other size). But how can I do this?
<div class="cards">
<div id="card1">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
<div id="card2">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
<div id="card3">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
</div>
This should work
.first-row{
display:flex;
}
.first-row .card{
flex:1;
}
.card{
border:5px solid black;
margin: 10px;
}
<div class="cards">
<div class='first-row'>
<div class='card' id="card1">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
<div class='card' id="card2">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
</div>
<div class='card' id="card3">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
</div>
Check it out.
.first-row{
display:flex;
}
.first-row .card{
flex:1;
}
.card{
border:5px solid black;
margin: 10px;
}
<div class="cards">
<div class='first-row'>
<div class='card' id="card1">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
<div class='card' id="card2">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
</div>
<div class='card' id="card3">
<img src="..." alt="Image" style="width: 100%">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
</div>
The Answer is CSS Flex Box ;)
section {
max-width: 740px;
margin: 0 auto;
display: flex;
}
.column {
margin: 10px;
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0;
}
section:nth-of-type(5) .column:first-of-type {
flex-grow: 2;
flex-shrink: 2;
flex-basis: 22px;
}
section:nth-of-type(6) .column:nth-of-type(2) {
flex-grow: 4;
flex-shrink: 4;
flex-basis: 66px;
}
/* OTHER STYLES */
html, body {
color: white;
height: 100%;
box-sizing: border-box;
}
body {
font-family: 'Raleway', sans-serif;
padding: 10px;
background: linear-gradient(135deg, #b04, #f80) fixed;
}
.column {
padding: 10px 0;
background-color: rgba(255, 0, 0, 0.25);
text-align: center;
border: 1px solid transparentize(white, 0.25);
background-color: transparentize(white, 0.8);
color: transparentize(white, 0.1);
}
<section>
<div class="column">One Third</div>
<div class="column">One Third</div>
<div class="column">One Third</div>
</section>
<section>
<div class="column">One Half</div>
<div class="column">One Half</div>
</section>
<section>
<div class="column">One Fourth</div>
<div class="column">One Fourth</div>
<div class="column">One Fourth</div>
<div class="column">One Fourth</div>
</section>
<section>
<div class="column">One Sixth</div>
<div class="column">One Sixth</div>
<div class="column">One Sixth</div>
<div class="column">One Sixth</div>
<div class="column">One Sixth</div>
<div class="column">One Sixth</div>
</section>
<section>
<div class="column">One Half</div>
<div class="column">One Fourth</div>
<div class="column">One Fourth</div>
</section>
<section>
<div class="column">One Sixth</div>
<div class="column">Two Thirds</div>
<div class="column">One Sixth</div>
</section>
.cards {
display: grid;
/* Make two tracks with the remaining space*/
grid-template-columns: 1fr 1fr;
grid-gap: 10px;
}
#card1,
#card2 {
background: #a03;
}
#card3 {
background: #be3;
/*Let card3 span 2 tracks*/
grid-column: span 2;
}
/*This will make the images span 100%*/
img {
max-width: 100%;
height: auto;
}
<div class="cards">
<div id="card1">
<img src="https://images.unsplash.com/photo-1440703281807-16ead562a596?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=f2b0cfa6c4950efda736ae4308c03420" alt="Image">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
<div id="card2">
<img src="https://images.unsplash.com/photo-1440703281807-16ead562a596?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=f2b0cfa6c4950efda736ae4308c03420" alt="Image">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
<div id="card3">
<img src="https://images.unsplash.com/photo-1440703281807-16ead562a596?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=f2b0cfa6c4950efda736ae4308c03420" alt="Image">
<div class="card-container">
<h4 class="class-text"><b>...</b></h4>
<p></p>
</div>
</div>
</div>

Masonry in order [duplicate]

This question already has answers here:
How to Create Grid/Tile View? [duplicate]
(8 answers)
Closed 5 years ago.
I'm doing a list of posts for a blog and I want to do in Masonry. The problems I have found are:
The order when I load the posts is in columns so the order is like next:
1 3 5
2 4 6
And I want:
1 2 3
4 5 6
If I solve the second problem, it makes white space between rows.
Next I show an image about my problem:
So I want a solution like the after Masonry image. I have added the code in this fiddler
The HTML is:
<ul id="posts">
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title 1</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title 2</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title <br> Lorem <br> Ipsum</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title ramdom <br> lore</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title for test</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title <br> test</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title <br> a <br> five</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
<li class="wow fadeInUp" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="bloglist text-center">
<div class="overflow"></div>
<div class="post-content">
<div class="listHeader">
<h1>Title</h1>
</div>
<div class="sbMeta">
<div class="loader"></div>
<div class="sbCats">Category</div>
<div class="sbAuth">
Author
</div>
</div>
<div class="sbFooter">
<i class="esen-Calendar"></i>Date
<i class="esen-Clock"></i>Min read
</div>
</div>
</div>
</li>
</ul>
and the CSS:
#posts li {
display: inline-block;
margin: 0;
padding: 0;
width: 33%;
background: #efefef;
}
#posts li .bloglist {
width: 100%;
position: relative;
border: 1px solid #f1f1f1;
padding-bottom: 22px;
overflow: hidden;
}
.text-center {
text-align: center;
}
#posts li .bloglist .overflow {
z-index: 2;
}
.overflow {
background-color: #3994ce;
mix-blend-mode: multiply;
opacity: .8;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
bottom: 0;
}
#posts li .bloglist .post-content {
position: relative;
z-index: 3;
}
#posts li .bloglist .post-content .listHeader {
position: relative;
margin-bottom: 20px;
}
#posts li .bloglist .post-content .sbMeta {
position: relative;
width: 100%;
}
#posts li .bloglist .post-content .sbMeta .loader {
height: 1px;
width: 100px;
margin: 0 auto;
margin-bottom: 20px;
position: relative;
background: #fff;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-ms-transition: all .5s ease;
transition: all .5s ease;
}
#posts li .bloglist .post-content .sbAuth {
width: 100%;
text-align: center;
margin-bottom: 40px;
}
#posts li .bloglist .post-content .sbAuth a {
color: #fff;
}
div {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#posts li .bloglist .post-content .sbFooter {
width: 90%;
position: absolute;
left: 50%;
transform: translate(-50%,0);
}
You can try creating masonry using column counts (CSS property).
Below is an example that can help you out.
HTML:
<ul id="posts">
<li>col 1</li>
<li>col 2</li>
<li>col 3</li>
<li>col 4</li>
<li>col 5</li>
<li>col 6</li>
</ul>
CSS:
#posts { /* Masonry container */
column-count: 3;
column-gap: 1em;
-moz-column-count: 3;
-moz-column-gap: 1em;
-webkit-column-count: 3;
-webkit-column-gap: 1em;
-ms-column-gap: 1em;
}
#posts li { /* Masonry bricks or child elements */
background-color: #eee;
display: inline-block;
margin: 0 0 1em;
width: 100%;
}
Here is the fiddle for it:-
https://jsfiddle.net/ug5oy087/