Align items based on title availability in CSS - html

I have created a panel as shows in the screenshots below. my panel will have a title heading and different icons which performs various operations. both these title heading and the icons are optional or in other words either one will not be available in many cases.
whenever i have title, i want all my icons to be at the extreme right side of the panel header which works fine as in first screenshot with the CSS i have written.
when i don't have a title i want all my icons to be on the extreme left side of the panel header as shown in second screenshot which i am facing difficulty to achieve.
SCREENSHOTS
HTML
<div class="panel">
<div class="panel-header ">Title Goes Here
<div class="toolbar-button-group">
<button class="toolbar-button-stroke icon-add"></button>
<button class="toolbar-button-stroke icon-hide"></button>
<button class="toolbar-button-stroke icon-edit"></button>
<button class="toolbar-button-stroke icon-options"></button>
</div>
</div>
<div class="panel-content "></div>
</div>
CSS
.panel {
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.23), 0 3px 12px rgba(0, 0, 0, 0.16);
background: #fff;
width: 100%;
height: 100%;
}
.panel-header {
color: #354052;
text-transform: capitalize;
font-size: 20px;
height: 40px;
line-height: 40px;
margin: 0;
padding-left: 24px;
border-bottom: 2px #BBBBBB solid;
}
.panel-content {
padding: 24px;
background: white;
}
.toolbar-button-stroke{
background:white;
border: none;
border-radius: 4px;
padding: 6px;
margin: 0px 3px;
color:black;
font-size: 15px;
text-transform: uppercase;
cursor:pointer;
outline: none;
}
.toolbar-button-group{
float: right;
}
i prefer CSS solutions with out positioning. Fiddle link here
Thanks in advance

If you can change your HTML around a bit to add an extra element, you can use :empty to target it based on the span having content or not with the next sibling selector.
.panel {
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.23), 0 3px 12px rgba(0, 0, 0, 0.16);
background: #fff;
width: 100%;
height: 100%;
}
.panel-header {
color: #354052;
text-transform: capitalize;
font-size: 20px;
height: 40px;
line-height: 40px;
margin: 0;
padding-left: 24px;
border-bottom: 2px #BBBBBB solid;
}
.panel-content {
padding: 24px;
background: white;
}
.toolbar-button-stroke {
background: white;
border: none;
border-radius: 4px;
padding: 6px;
margin: 0px 3px;
color: black;
font-size: 15px;
text-transform: uppercase;
cursor: pointer;
outline: none;
}
.toolbar-button-group {
float: right;
}
span:empty + .toolbar-button-group {
float: left;
}
<div class="panel">
<div class="panel-header "><span>Title Goes Here</span>
<div class="toolbar-button-group">
<button class="toolbar-button-stroke icon-add">A</button>
<button class="toolbar-button-stroke icon-hide">B</button>
<button class="toolbar-button-stroke icon-edit">C</button>
<button class="toolbar-button-stroke icon-options">D</button>
</div>
</div>
<div class="panel-content "></div>
</div>
<br/>
<div class="panel">
<div class="panel-header "><span></span>
<div class="toolbar-button-group">
<button class="toolbar-button-stroke icon-add">A</button>
<button class="toolbar-button-stroke icon-hide">B</button>
<button class="toolbar-button-stroke icon-edit">C</button>
<button class="toolbar-button-stroke icon-options">D</button>
</div>
</div>
<div class="panel-content "></div>
</div>

Solution is simple: https://jsfiddle.net/45kuucbn/1/
Add span tag around your title, if is present use + to add style to button group.
<div class="panel">
<div class="panel-header ">
<span>Title Goes Here</span>
<div class="toolbar-button-group">
<button class="toolbar-button-stroke icon-add">a</button>
<button class="toolbar-button-stroke icon-hide">a</button>
<button class="toolbar-button-stroke icon-edit">a</button>
<button class="toolbar-button-stroke icon-options">a</button>
</div>
</div>
<div class="panel-content "></div>
</div>
<div class="panel">
<div class="panel-header ">
<div class="toolbar-button-group">
<button class="toolbar-button-stroke icon-add">a</button>
<button class="toolbar-button-stroke icon-hide">a</button>
<button class="toolbar-button-stroke icon-edit">a</button>
<button class="toolbar-button-stroke icon-options">a</button>
</div>
</div>
<div class="panel-content "></div>
</div>
.panel {
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.23), 0 3px 12px rgba(0, 0, 0, 0.16);
background: #fff;
width: 100%;
height: 100%;
}
.panel-header {
color: #354052;
text-transform: capitalize;
font-size: 20px;
height: 40px;
line-height: 40px;
margin: 0;
padding-left: 24px;
border-bottom: 2px #BBBBBB solid;
}
.panel-content {
padding: 24px;
background: white;
}
.toolbar-button-stroke{
background:white;
border: none;
border-radius: 4px;
padding: 6px;
margin: 0px 3px;
color:black;
font-size: 15px;
text-transform: uppercase;
cursor:pointer;
outline: none;
}
.toolbar-button-group{
display:inline-block;
}
.panel-header span + .toolbar-button-group {
float:right;
}

when text heading block code works like what you want
here is codepen.io live example
if( $('.left').is(':empty') ) {
$('.right').addClass('full');
$('.left').addClass('hidden');
}
.title-container {
width: 300px;
margin: 100px auto;
outline: 1px solid #333;
padding: 15px 25px;
font-family: Arial, sans-serif;
font-size: 12px;
}
.title-container .col-2 {
width: 50%;
float: left;
outline: 1px solid #ccc;
padding: 5px;
box-sizing: border-box;
}
.title-container .hidden {
display: none;
}
.title-container .icon {
display: inline-block;
outline: 1px solid #ccc;
width: 20px;
text-align: center;
}
.title-container .right {
text-align: right;
}
.title-container .full {
width: 100%;
}
.title-container .full.right {
text-align: left;
}
.title-container::after {
display: table;
content: "";
clear: both;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="title-container">
<div class="col-2 left heading">Delete me and see result</div> <!-- heading block-->
<div class="col-2 right icons"> <!-- icons block -->
<span class="icon">1</span>
<span class="icon">2</span>
<span class="icon">3</span>
</div>
</div>

Related

How to set Horizontal/Inline multiple view using Google App Script for Gmail Addon Plugin

How to set Horizontal/Inline multiple view using Google App Script for Gmail Addon Plugin.
I have prepared the demo for the vertical views but I don't know how to set the view Horizontally/Inline which is shown in the below image.
I have also tried with the help of HTML file but may be it's not rendering perfectly.
https://i.imgur.com/ZCbUUvw.png
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
.d-flex{
display: flex
}
.text-center{
text-align: center;
}
.header-section{
border-bottom: 1px solid;
border-bottom-color: rgba(0, 0, 0, 0.12);
padding: 10px;
}
.header-image{
background-color: #eaeaea;
text-align: center;
width: 36px;
height: 36px;
background-size: cover;
border-radius: 100%;
padding: 0;
margin-right: 12px;
}
h1.header-title{
margin: 0;
font-size: 16px;
}
h2.header-subtitle{
margin: 0;
font-size: 14px;
}
h3.body-section-title{
font-size:13px;
}
.mail-list-item{
display: flex;
flex-direction: row;
align-items: center;
/* justify-content: space-between; */
margin-bottom: 16px;
}
h4.f-l-name{
font-size: 14px;
margin: 0;
}
h5.mail{
font-size: 13px;
color: rgba(0, 0, 0, 0.4);
margin: 0;
}
h4.company-name{
font-size: 14px;
margin: 0;
padding: 0 0 10px 0;
border-bottom: 1px solid;
border-bottom-color: rgba(0, 0, 0, 0.12);
}
.upload-deck-btn{
margin-top: 42px;
text-transform: uppercase;
align-items: center;
padding: 10px;
gap: 10px;
width: 114px;
height: 36px;
background: #0F99FF;
border-radius: 4px;
color: #fff;
border: none;
}
.add-deal-btn{
text-transform: uppercase;
align-items: center;
padding: 10px;
gap: 10px;
width: 114px;
height: 36px;
background: #0F99FF;
border-radius: 4px;
color: #fff;
border: none;
}
</style>
</head>
<body>
<div class="header-section d-flex">
<div class="header-image"></div>
<div>
<h1 class="header-title">Fintee Seed Tound</h1>
<h2 class="header-subtitle">James McAvoy</h2>
</div>
</div>
<div class="body-section">
<h3 class="body-section-title">Who's the founder?</h3>
<div class="mail-list">
<div class="mail-list-item">
<div>
<h4 class="f-l-name">First Last Name</h4>
<h5 class="mail">Email#gmail.com</h5>
</div>
<input type="checkbox">
</div>
<div class="mail-list-item">
<div>
<h4 class="f-l-name">First Last Name</h4>
<h5 class="mail">Email#gmail.com</h5>
</div>
<input type="checkbox">
</div>
</div>
<h4 class="company-name">Company Name</h4>
<div class="text-center">
<input type="button" value="Upload Deck" class="upload-deck-btn">
<div class="d-flex">
<h4>Invite Founder to complete profile?</h4>
<input type="checkbox" >
</div>
<h3 class="add-deal-msg">Add this deal to Outpost?</h3>
<input type="button" value="Add Deal" class="add-deal-btn" >
</div>
</div>
</body>
</html>
Code.gs
function htmlFun() {
var html = HtmlService.createTemplateFromFile('Index').evaluate().getContent();
return CardService.newCardBuilder()
.addSection(CardService.newCardSection().addWidget(CardService.newKeyValue().setContent(html)))
.build();
}
Need to do like shown in image either it's using google script or using html inside google script.

Anchor tag isn't displaying and is greyed out in in dev tools

I have been fighting with this section of code for a good few hours and cant figure out why it's greyed out in the browser and in dev tools. its suppose to display a title of the listed item. So far Im not seeing any Title unless I remove the class="ad-box-title" from the tag.
CSS
/*Ad box*/
.modern-img-indicator{
position: absolute;
top: 0;
left: 0;
background: rgba(0,0,0, 0.2);
font-size: 11px;
padding: 5px;
color: #ffffff;
}
.ad-box {
background: #fff none repeat scroll 0 0;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
position: relative;
margin-bottom: 20px;
}
.ad-box .ads-thumbnail {
display: block;
overflow: hidden;
position: relative;
border-radius: 3px 3px 0 0;
height: 158px;
}
.ad-box .caption {
background: #fff none repeat scroll 0 0;
padding: 7px 10px;
}
.ad-box-caption-title {
height: 32px;
margin-bottom: 5px;
overflow: hidden;
}
.ad-box-caption-title .ad-box-title {
color: #666666;
}
.ad-box-category {
font-size: 11px;
height: 30px;
border-top: 1px solid #e7e7e7;
line-height: 30px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ad-box-footer {
background-color: #f6f6f6;
border-radius: 0 0 3px 3px;
border-top: 1px solid #e7e7e7;
box-shadow: 0 1px 0 0 #fff inset;
padding: 5px 8px;
position: relative;
}
span .ad-box-footer, .ad-box-price {
display: block;
}
.ad-box-price {
font-size: 12px;
}
.ad-box-premium i {
margin-top: 7px;
color: #f21aa5;
}
.ad-box-premium {
border-left: 1px solid #ddd;
color: #aaa;
cursor: default;
height: 28px;
position: absolute;
right: 1px;
text-align: center;
top: 1px;
transition: color 0.15s linear 0s;
width: 29px;
}
.ad-box-premium img {
max-height: 25px;
width: auto;
}
.countdown{
padding: 5px;
font-size: 14px;
text-align: center;
}
.place-bid-btn{
text-align: center;
}
HTML
<div class="col-md-3">
<div class="ad-box">
<!-- Thumbnail -->
<div class="ads-thumbnail">
<a href="#">
<img src="/uploads/thumbs/cat.jpg" alt="Auction title" class="img-fluid">
<span class="modern-img-indicator">
<i class="far fa-file-image"></i>
</span>
</a>
</div>
<!-- Caption -->
<div class="caption">
<div class="ad-box-caption-title">
<a href="#" class="ad-box-title">
Title Here
</a>
</div>
<div class="ad-box-category">
<a href="#" class="price text-muted">
<i class="far fa-folder"></i> Category Name Here
</a>
<a href="#" class="price text-muted">
<i class="fas fa-map-marker-alt"></i> Location Here
</a>
</div>
</div>
<!-- Box footer -->
<div class="ad-box-footer">
<span class="ad-box-price">Starting price here $0.00</span>
<span class="ad-box-price">Current Bid here $0.00</span>
<!-- If its a premium auction -->
<div class="ad-box-premium">
<img src="/images/premium-icon.png" alt="Premium Auction Image here">
</div>
<!-- Countdown -->
<div class="countdown">Time remaining</div>
<div class="place-bid-btn">
Place Bid
</div>
</div>
</div>
</div>

Position search bar and button on an background image with bootstrap and CSS

I am trying to position the search bar on a background image. I am also trying to position a button at the bottom and center of the image. Following that, I will have containers.
What I am trying to achieve.
But what I am stuck and confused with positioning. The glyphicon is not working as well?
My Code
<style>
.card {
border: 0px solid;
}
.drop-shadow {
-webkit-box-shadow: 0 0 2px 2px rgba(0, 0, 0, .5);
box-shadow: 0 0 10px 1px rgb(211, 211, 211, 0.8);
border-radius: 0px;
}
.container-fluid {
width: auto
}
.container-fluid.drop-shadow {
margin-top: 2%;
margin-left: 5%;
margin-right: 5%
}
.img-fluid {
height: 200px;
}
#child {
width: 100%;
height: 20px;
margin: auto;
text-align: center;
bottom: 0px;
position: absolute;
}
.btn-checkin {
display: inline-block;
text-align: center;
white-space: nowrap;
color: #fff;
border-color: #EC008c;
text-transform: uppercase;
background-color: #EC008c;
font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
padding: 0.375rem .75rem;
font-size: 13px;
border-radius: .25rem;
}
</style>
</head>
<body id="page-top">
<div class="card">
<img class="img-fluid" src="img/1847p.png" alt="Card image cap">
<div class="col-md-5">
<div class="form-group">
<div class="icon-addon addon-lg">
<input type="text" placeholder="Search Class" class="form-control" style="height:30px;position:absolute" id="email">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
</div>
</div>
</div>
<div id="child">
<button class="btn-checkin">Check in</button>
<div class="container-fluid drop-shadow">
<div class="row">
frsjafksdalkdfsa
</div>
fsdfdasasd
</div>
</div>
</div>
Problems to target :
Get the search bar on the background pic
Set the background pic always on top of the screen with full width but with certain height. I currently hard coded the height to 200px. Is there a way that it can be responsive?
I am also stuck with the glyphycon issue, why is it not displayed?
How do I position the button at the bottom of the image and in the
center?
Use margin-top with negative value to make the form goes on the image.
Glyphicons look to be working great simply here.
* {
box-sizing: border-box;
}
img {
width: 100%;
}
div#form-box {
margin-top: -95px;
text-align: center;
}
div#input-group {
width: 80%;
margin: 0 auto 20px;
position: relative;
background-color: #fff;
border: none;
border-radius: 5px;
}
input#email, label[for="email"] {
display:inline-block;
vertical-align: middle;
}
input#email {
width: calc(100% - 40px);
padding: 10px;
border: none;
}
label[for="email"] {
width: 40px;
line-height: 40px;
}
button#btn-checkin {
display: inline-block;
padding: 6px 10px;
border: none;
border-radius: 5px;
background-color: #EC008c;
color: #fff;
text-align: center;
text-transform: uppercase;
}
<head>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" />
</head>
<img src="http://wonderfulengineering.com/wp-content/uploads/2016/01/Desktop-Wallpaper-4.jpg" />
<div id="form-box">
<form>
<div id="input-group">
<label for="email" class="glyphicon glyphicon-search"></label><!--
--><input type="text" placeholder="Search Class" id="email">
</div>
<br/>
<button id="btn-checkin">Check-in</button>
</form>
</div>
<br/>
<br/>
<br/>
.card{
border:0px solid;
position:relative;
height:200px;
background:url('https://preview.ibb.co/fex0wK/1847p.png') no-repeat top center;
background-size:cover;
}
.card img {
width:100%;
}
.search-box {
position : absolute;
display:inline-block;
bottom:-30px;
left:0;
right:0;
padding:15px;
text-align:center;
}
.drop-shadow {
-webkit-box-shadow: 0 0 2px 2px rgba(0, 0, 0, .5);
box-shadow: 0 0 10px 1px rgb(211, 211, 211, 0.8);
border-radius:0px;
}
.container-fluid{
width:auto
}
.container-fluid.drop-shadow {
margin-top:2%;
margin-left:5%;
margin-right:5%
}
.img-fluid {
height: 200px;
}
#child{
width:100%;
height: 20px;
margin: auto;
text-align: center;
margin-top: 40px;
}
.form-group {
width:100%;
margin-bottom:10px;
}
.btn-checkin{
display: inline-block;
text-align: center;
white-space: nowrap;
color: #fff;
border-color: #EC008c;
text-transform: uppercase;
background-color: #EC008c;
font-family:'Open Sans','Helvetica Neue',Arial,sans-serif;
padding: 0.375rem .75rem;
font-size: 13px;
border-radius: .25rem;
}
.icon-addon {
position:relative;
}
.icon-addon label {
position: absolute;
left: 2px;
top: 2px;
padding: 8px;
font-size: 20px;
}
.icon-addon input {
height:40px;
padding-left:35px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<body id="page-top">
<div class="card" >
<!-- <img class="img-fluid" src="img/1847p.png" alt="Card image cap"> -->
<div class="search-box">
<div class="form-group">
<div class="icon-addon addon-lg">
<input type="text" placeholder="Search Class" class="form-control" id="email">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
</div>
</div>
<button class="btn-checkin">Check in</button>
</div>
</div>
<div id="child">
<div class="container-fluid drop-shadow">
<div class="row">
frsjafksdalkdfsa
</div>
fsdfdasasd
</div>
</div>
Try this code...If you need any help, let me know.
Ok so you want to position the search bar inside a image.
Make a div with the image as background
background: image_source;
background-size: contain;
position: relative; //must to write
width: 100%;
height: 100px; //as much as you want
Then the css for search bar
position: absolute;
then use top, left,etc to position the search bar

Put two divs one near the other

I have the following html code:
<div class="demand page">
<div id="crumby-title">
<div class="page-icon">
<i class="fa fa-line-chart"></i>
</div>
<div class="page-title">
Demand
</div>
</div>
<div id="chart" class="demand-chart">
</div>
</div>
and the css/less:
.rtm {
.app__header {
background-color: #ffffff;
box-shadow: 1px 2px 2px rgba(1, 1, 1, 0.15);
}
.app__inner-content {
background-color: #ffffff;
}
.demand-chart{
padding-top: 50px;
}
#crumby-title {
display: block;
border-bottom: 1px solid #eee;
}
.page-icon {
font-size: 20px;
position: absolute;
padding: 14px 18px;
background: #e7e7e7;
}
.page-title {
float: left;
font-size: 20px;
font-weight: 5px 10px 10px 75px;
height: 55px;
}
}
I tried to do like this in order to show the page-icon and page-title one near the other but how it is done now they are one over the other (the icon is on top of the title)
How can I solve this? Thanks
When you say "near each other" I am assuming you mean "beside each other".
You can add flexbox properties to #crumby-title. Then remove position and float properties from .page-icon and page-title. You can also remove height from .page-title
.app__header {
background-color: #ffffff;
box-shadow: 1px 2px 2px rgba(1, 1, 1, 0.15);
}
.app__inner-content {
background-color: #ffffff;
}
.demand-chart {
padding-top: 50px;
}
#crumby-title {
display: flex;
align-items: center;
border-bottom: 1px solid #eee;
}
.page-icon {
font-size: 20px;
padding: 14px 18px;
background: #e7e7e7;
}
.page-title {
font-size: 20px;
font-weight: 5px 10px 10px 75px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="demand page">
<div id="crumby-title">
<div class="page-icon">
<i class="fa fa-line-chart"></i>
</div>
<div class="page-title">
Demand
</div>
</div>
<div id="chart" class="demand-chart">
</div>
</div>
Give float:left to .page-icon instead of position:absolute and add <div class="clear"></div> after page-title.
.app__header {
background-color: #ffffff;
box-shadow: 1px 2px 2px rgba(1, 1, 1, 0.15);
}
.app__inner-content {
background-color: #ffffff;
}
.demand-chart{
padding-top: 50px;
}
#crumby-title {
display: block;
border-bottom: 1px solid #eee;
}
.page-icon {
font-size: 20px;
float: left;
padding: 14px 18px;
background: #e7e7e7;
}
.page-title {
float: left;
font-size: 20px;
font-weight: 5px 10px 10px 75px;
height: 55px;
}
.clear{
clear:both;
}
<div class="demand page">
<div id="crumby-title">
<div class="page-icon">
<i class="fa fa-line-chart"></i>
</div>
<div class="page-title">
Demand
</div>
<div class="clear"></div>
</div>
<div id="chart" class="demand-chart">
</div>
</div>
I want to show u another version of ankita pantel's put them in a table and add padding-top to Demand
.app__header {
background-color: #ffffff;
box-shadow: 1px 2px 2px rgba(1, 1, 1, 0.15);
}
.app__inner-content {
background-color: #ffffff;
}
.demand-chart{
padding-top: 50px;
}
#crumby-title {
display: block;
border-bottom: 1px solid #eee;
}
.page-icon {
font-size: 20px;
padding: 14px 18px;
background: #e7e7e7;
}
.page-title {
padding-top: 30px;
float: left;
font-size: 20px;
font-weight: 5px 10px 10px 75px;
height: 55px;
}
<div class="demand page">
<div id="crumby-title">
<table>
<tr>
<td>
<div class="page-icon">
<i class="fa fa-line-chart"></i>
</div>
</td>
<td>
<div class="page-title">
Demand
</div>
</td>
</tr>
</table>
</div>
<div id="chart" class="demand-chart">
</div>
</div>
All the cool kids are using flex box.
display:flex; flex-direction:row; makes the child items stack in a row. (flex-direction:row is default so you can skip that)
#crumby-title {
...
display: flex;
flex-direction:row;
}
then you can (if you want) center the text with
.page-title {
....
display: flex;
align-items: center;
}
Fiddle

children not staying inside parent divs

Fiddle: https://jsfiddle.net/uatzust3/
Here is the fiddle for my problem, you'll observe that the children are not staying inside the parent div card and also I want the divs to take full width of parent which they are not taking.
Also, where should I be learning best practices? I am new to the community. Thanks in advance.
The left div(black_container) is short of content but should arrange the height according to the width of the right div(content_container) all the while staying inside the card div.
.card {
box-shadow: 0 25px 45px rgba(0, 0, 0, 0.30), 0 15px 15px rgba(0, 0, 0, 0.22);
max-width: 800px;
margin: auto;
position: relative;
}
.black_container {
height: inherit;
background: #333;
display: inline-block;
vertical-align: top;
padding: 3%;
font-family: 'Nunito', sans-serif;
}
.content_container {
display: inline-block;
padding: 3%;
/* position: absolute;
top:0;
bottom: 0; */
}
.small_bar {
padding: 3px;
width: 30px;
margin: 0 auto;
background: #e4e4e4;
margin-top: 35px;
}
.name {
color: #fff;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 5px;
margin: 30px auto 5px auto;
text-align: center;
font-weight: 800;
}
.designation {
font-size: 10px;
margin: 0 auto;
}
.qrcode_container {
float: right;
}
.qr_container {
overflow: auto;
width: 100%;
}
.qr_text {
display: inline-block;
list-style-type: none;
}
.qr_text>li {
font-size: 18px;
font-weight: 600;
letter-spacing: 2.5px;
color: #9a9a9a;
}
.bars {
display: inline-block;
position: relative;
top: 10px;
}
.bars .small_bar {
width: 15px;
background: #777;
}
.bar {
position: absolute;
top: -80px;
}
.qr_code {
display: inline-block;
height: inherit;
border: 1px solid #e4e4e4;
padding: 5px;
}
.button {
width: 150px;
letter-spacing: 1;
text-transform: uppercase;
font-weight: 600;
color: #fff;
text-align: center;
background: #333;
padding: 5px 10px;
}
<div class="card">
<div class="black_container">
<div class="circular">
</div>
<p class="small_bar"></p>
<p class="name">wow</p>
<p class="name designation">Front-End Designer</p>
</div>
<div class="content_container">
<!-- qr code container ends -->
<div class="qr_container">
<div class="qrcode_container">
<ul class="qr_text">
<li>LOREM</li>
<li>IPSUM</li>
<li>DPOLER</li>
</ul>
<div class="bars">
<div class="small_bar bar"></div>
<div class="small_bar"></div>
</div>
<div class="qr_code"></div>
</div>
</div>
<!-- qr code container ends -->
<div class="card_content">
<p>Hello!</p>
<p>My name is lorem</p>
<p>I am a web designer</p>
<p>Im stuck</span>
</p>
<div class="button">button</div>
</div>
<div class="card_footer"></div>
</div>
</div>
A parent cannot take the height of a direct child if the child is absolute because the absolute elements are removed from the document flow(like floats), so in this case "card" doesn't even know "content_container" even exists .
https://jsfiddle.net/OmarIsComing/eq4L86g9/1/
update:
solution with flexbox: https://jsfiddle.net/OmarIsComing/eq4L86g9/2/
solution without flexbox: https://jsfiddle.net/OmarIsComing/eq4L86g9/3/
If flexbox is an option, this is easy :
Add display: flex to your card
Add flex: 1 to the content-container
See demo below:
.card {
box-shadow: 0 25px 45px rgba(0, 0, 0, 0.30), 0 15px 15px rgba(0, 0, 0, 0.22);
max-width: 800px;
margin: auto;
position: relative;
display: flex;
}
.black_container {
height: inherit;
background: #333;
display: inline-block;
vertical-align: top;
padding: 3%;
font-family: 'Nunito', sans-serif;
}
.content_container {
display: inline-block;
padding: 3%;
/* position: absolute;
top:0;
bottom: 0; */
flex: 1;
}
.small_bar {
padding: 3px;
width: 30px;
margin: 0 auto;
background: #e4e4e4;
margin-top: 35px;
}
.name {
color: #fff;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 5px;
margin: 30px auto 5px auto;
text-align: center;
font-weight: 800;
}
.designation {
font-size: 10px;
margin: 0 auto;
}
.qrcode_container {
float: right;
}
.qr_container {
overflow: auto;
width: 100%;
}
.qr_text {
display: inline-block;
list-style-type: none;
}
.qr_text>li {
font-size: 18px;
font-weight: 600;
letter-spacing: 2.5px;
color: #9a9a9a;
}
.bars {
display: inline-block;
position: relative;
top: 10px;
}
.bars .small_bar {
width: 15px;
background: #777;
}
.bar {
position: absolute;
top: -80px;
}
.qr_code {
display: inline-block;
height: inherit;
border: 1px solid #e4e4e4;
padding: 5px;
}
.button {
width: 150px;
letter-spacing: 1;
text-transform: uppercase;
font-weight: 600;
color: #fff;
text-align: center;
background: #333;
padding: 5px 10px;
}
<div class="card">
<div class="black_container">
<div class="circular">
</div>
<p class="small_bar"></p>
<p class="name">wow</p>
<p class="name designation">Front-End Designer</p>
</div>
<div class="content_container">
<!-- qr code container ends -->
<div class="qr_container">
<div class="qrcode_container">
<ul class="qr_text">
<li>LOREM</li>
<li>IPSUM</li>
<li>DPOLER</li>
</ul>
<div class="bars">
<div class="small_bar bar"></div>
<div class="small_bar"></div>
</div>
<div class="qr_code"></div>
</div>
</div>
<!-- qr code container ends -->
<div class="card_content">
<p>Hello!</p>
<p>My name is lorem</p>
<p>I am a web designer</p>
<p>Im stuck</span>
</p>
<div class="button">button</div>
</div>
<div class="card_footer"></div>
</div>
</div>
Use the class card-body, this will keep the contents inside of the card.
<div class="card border-success">
<div class="card-header border-success">
<h3 class="card-title">Card Title</h3>
</div>
<div class="card-body border-success">
<dl>
<dt>
Stuff
</dt>
<dd>
Stuff Details
</dd>
</dl>
</div>
</div>
replace the .content_container css with:
.content_container {
display: inline-block;
padding: 3%;
vertical-align: top;
}
I think the CSS attribute position: absolute; is causing this issue. In short, absolute position removes the element from the flow of other elements; therefore, its height is simply ignored, and never counted in your .card container.