Create 3 price boxes with Bootstrap - css

I would like to create 3 boxes with equal height using Bootstrap but I am not sure how to do it.
I found I can use flexbox and my main boxes will be equal height but I want some inner div to have border and that div to fill the main div and I cannot do it.
I have also some other problems: how to position button at the center bottom of that div and I have there also some description paragraph and I would like those paragrahps also to be equal heights, because I use some border at the bottom.
Here is my example code:
<div class="container text-center">
<div class="row">
<div class="col-md-4">
<div class="box">
<div class="box-header">
</div>
<div class="box-body">
<p class="box-info">Some description of product 1</p>
<ul class="box-list">
<li>test</li>
<li>test</li>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
<button class="btn btn-default">Register</button>
</div>
</div>
</div>
<div class="col-md-4">
<div class="box">
<div class="box-header">
</div>
<div class="box-body">
<p class="box-info">Some description of product 2 which can be very loooooooooooooong</p>
<ul class="box-list">
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
<button class="btn btn-default">Register</button>
</div>
</div>
</div>
<div class="col-md-4">
<div class="box">
<div class="box-header">
</div>
<div class="box-body">
<p class="box-info">Some description of product 3</p>
<ul class="box-list">
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
<button class="btn btn-default">Register</button>
</div>
</div>
</div>
</div>
</div><!-- /.container -->
Css:
body {
padding-top: 50px;
}
.box-header {
height: 100px;
background-color: blue;
text-align: center;
}
.box-body {
position: relative;
padding: 20px 30px;
border: 1px solid green;
border-top: none;
}
.box-info {
border-bottom: 1px solid #e7e7e7;
}
.box-list {
text-align: left;
}
My description can not be clear, so you can find a Bootply here.

Related

How can I make the height of two separate unordered list items the same height?

For context, here's what it looks like. In the second unordered list, I would like the items to have the same height as the items in the first unordered list even though they don't have sections 2 or 3. Is this possible using flexbox or any other type of css? I'm trying to avoid calculating heights using JS. In the snippet below, I'm using pure css, but in my actual code, I'm using less.
EDIT: I can't hard-code the height because the sections are dynamic and generated by data retrieved from an API. Additionally, I can't make them vertically scrollable.
Code:
<html>
<head>
<style>
.module {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.module .container_wrapper {
border: solid 1px;
}
.module .panes-2 {
flex: 0 0 49%;
}
.module .card {
display: inline-block;
border: solid 1px;
}
</style>
</head>
<body>
<section class="module">
<div class="container_wrapper panes-2">
<ul>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
</ul>
</div>
<div class="container_wrapper panes-2">
<ul>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
</ul>
</div>
</section>
</body>
</html>
I did a little research.
Not sure if this is what you are looking for, but using bootstrap could help:
<div class="container-fluid content-row">
<div class="row">
<div class="col-sm-12 col-lg-6">
<div class="card h-100">
… content card …
</div>
</div>
… all the other cards …
</div>
</div>
.card {
height: 500px;
overflow-y: scroll;
}
Also you can use overflow-y: auto;

How to make the header take up the full width in a media query?

I wrote the media queries for smaller screens ,but i can not seem to make them work for ipads. I have a problem with the width of the header and the navbar. They don't seem to take up the full width even though I wrote margin and padding 0 (as an asterisk). The max-width of the html is 1600px. Here is a Print screen.
<header>
<div class="Header-TopContainer">
<div class="Header-MyAccountItem">
<i class="fas fa-user account "></i>
</div>
<div class="Header-MyAccount">
My Account
</div>
<div class="Header-CartItem">
<i class="fas fa-cart-plus cart"></i>
</div>
<div class="Header-Cart">
Cart
</div>
<div class="Header_CheckoutItem">
<i class="fas fa-check-circle check"></i>
</div>
<div class="Header-Checkout">
Checkout
</div>
<div class="Header-VerticalLine"><img src="./Images/first%20hr.png" alt="vertical line"></div>
<div class="Header-Search"><i class="fas fa-search" id="search"></i></div>
</div>
<div class="line mqtablet">
<img src="./Images/long.png" alt="vertical line">
</div>
<div class="Header-LogoContainer mqtablet">
<div class="Header-LogoText">
<h1>Car<span style="color:#ff3448">Store</span></h1>
<p class="Header-LogoSubText">Best Car Seller</p>
</div>
<div class="Header-Phone">
<div class="Header-PhoneIcon">
<i class="fas fa-mobile-alt mobile"></i>
<h2>+123 456 7890</h2>
</div>
<div class="Header-PhoneNumber">
<p class="Header-WorkingHours">mon-fri:8:30am-7:30pm; sat-sun:9:30am-4:30pm</p>
</div>
</div>
<div class="Header-container">
<div class="Header-Wishlist">
<div class="Header-WishlistVLine vline">
<img src="./Images/first%20hr.png" alt="vertical line">
</div>
<div class="Wishlist">
<div class="Header-WishlistIcon">
<i class="fas fa-star wishlisticon"></i>
</div>
<div class="Header-WishlistText">
Wishlist
</div>
</div>
</div>
<div class="Header-Compare">
<div class="Header-WishlistVLine">
<img src="./Images/first%20hr.png" alt="vertical line">
</div>
<div class="Compare">
<div class="Header-CompareIcon">
<i class="fas fa-car compareicon"></i>
</div>
<div class="Header-CompareText">
Compare
</div>
</div>
</div>
<div class="Header-MyCart">
<div class="Header-WishlistVLine">
<img src="./Images/first%20hr.png" alt="vertical line">
</div>
<div class="Mycart">
<div class="Header-MyCartIcon">
<i class="fas fa-cart-plus cart mycarticon"></i>
</div>
<div class="Header-MyCartText'">
My cart
</div>
</div>
</div>
</div>
</div>
</header>
<nav class="toggle-menu">
<label for="toggle">☰</label>
<input type="checkbox" id="toggle"/>
<ul class="MainMenu">
<li>Home</li>
<li>Services</li>
<li>About</li>
<li>Reviews</li>
<li>Locations</li>
<li>Contacts</li>
</ul>
</nav>
#media(min-width:768px) and (max-width:1024px) {
header {
position: relative;
height: 17rem;
text-align: center;
}
.Header-TopContainer,
.Header-Phone {
display: none;
}
.mqtablet {
display: flex;
flex-direction: column;
text-align: center;
}
.Header-LogoText {
margin: 0.5rem;
}
.line {
position: absolute;
top: 9rem;
}
.Header-container {
margin-left: 10%;
}
.vline {
display: none;
}
nav {
text-align: center;
}
ul {
flex-wrap: nowrap;
justify-content: flex-end;
padding-right: 9rem;
}
ul li a {
padding-left: 5rem;
}

Bootstrap footer is overlapping the content on small screens?

I have an issue with my bootstrap layout.
Basically, everything looks OK on larger screens but on smaller screens my footer overlaps the content or the content overlaps the footer!
This is the code I have: https://jsfiddle.net/xpvt214o/639029/
If you make the HTML part larger and smaller and look at the footer, you will see the issue.
This is my full code:
html,body,.col-md-12,.row {
height:100%;
}
.row > div {
height:100%;
}
.YOsidemenu{
padding:0;
font-weight:bold;
background-color: #ffc90e;
padding-top:10px;
max-width:200px;
}
#media only screen and (max-width:768px) {
.YOsidemenu{
display:none;
}
}
/* to make columns visible */
.row .col-sm-2 {
background-color:red;
}
.row .col-sm-10 {
background-color:green;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div style="height:100%; background:#fff;width:100%;padding:0;" class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2">
Sidebar content
</div>
<div class="col-sm-10">
Body content
</div>
</div>
</div>
</div>
<!-- Footer -->
<section id="footer" style="text-align:left; !important">
<div class="container">
<div class="row text-center text-xs-center text-sm-left text-md-left" style="text-align:left; !important">
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Quick links</h5>
<ul class="list-unstyled quick-links">
<li>Home</li>
<li>Help</li>
<li>Sign-in</li>
<li>affiliate</li>
<li>Promote</li>
</ul>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Support</h5>
<ul class="list-unstyled quick-links">
<li><i class="fa fa-envelope"></i>support#email.com</li>
<li><i class="fa fa-phone-square"></i>+44 7842227819</li>
<li><i class="fa fa-globe"></i>www.website.com</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 mt-2 mt-sm-2 text-center text-white">
<p>this site a registered company. </p>
<p class="h6">&copy All right Reversed.<a class="text-green ml-2" href="https://www.website.com" target="_blank">website</a></p>
</div>
</hr>
</div>
</div>
</section>
<!-- ./Footer -->
Could someone please be kind enough and help me with this issue?
Thanks in advance.
Try removing height: 100% from the div. On mobile the container is 100% high, but because the columns get stacked and each column inherits the height, you have a parent with 100% height and two columns with each 100%, making it 200% of height.
Is this what you are looking for?
html,
body,
.col-md-12,
.row {
height: 100%;
}
.row>div {
height: 100%;
}
.YOsidemenu {
padding: 0;
font-weight: bold;
background-color: #ffc90e;
padding-top: 10px;
max-width: 200px;
}
#media only screen and (max-width:768px) {
.YOsidemenu {
display: none;
}
}
/* to make columns visible */
.row .col-sm-2 {
background-color: red;
}
.row .col-sm-10 {
background-color: green;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div style="height:100%; background:#fff;width:100%;padding:0;" class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2 col-xs-2">
Sidebar content
</div>
<div class="col-sm-10 col-xs-10">
Body content
</div>
</div>
</div>
</div>
<!-- Footer -->
<section id="footer" style="text-align:left; !important">
<div class="container">
<div class="row text-center text-xs-center text-sm-left text-md-left" style="text-align:left; !important">
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Quick links</h5>
<ul class="list-unstyled quick-links">
<li>Home</li>
<li>Help</li>
<li>Sign-in</li>
<li>affiliate</li>
<li>Promote</li>
</ul>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Support</h5>
<ul class="list-unstyled quick-links">
<li><i class="fa fa-envelope"></i>support#email.com</li>
<li><i class="fa fa-phone-square"></i>+44 7842227819</li>
<li><i class="fa fa-globe"></i>www.website.com</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 mt-2 mt-sm-2 text-center text-white">
<p>this site a registered company. </p>
<p class="h6">&copy All right Reversed.<a class="text-green ml-2" href="https://www.website.com" target="_blank">website</a></p>
</div>
</hr>
</div>
</div>
</section>
<!-- ./Footer -->

How to display child component from left to right

I am rendering child component in for loop from parent component. My parent component should be float to right at the bottom of screen then after each render of child component should be render to left to my parent component
Parent component :
<div class="row">
<div class="content">
<div class="row">
<div class="col-md-12" id="ng-chat-view">
<div class="col-md-3">
<div id="ng-chat-people" [ngClass]="{'ng-chat-people-collapsed':isCollapsed}">
<a href="javascript:void(0);" class="ng-chat-title shadowed" (click)="onChatTitleClicked($event)">
<span>
Farmer List
</span>
</a>
<input *ngIf="!isCollapsed" id="ng-chat-search_friend" type="search" placeholder="Search" [(ngModel)]="search" (ngModelChange)="getFarmerBySearchVal(search)"
/>
<ul id="ng-chat-users" *ngIf="!isCollapsed">
<li *ngFor="let user of farmers">
<div *ngIf="!user.imageUrl" class="icon-wrapper">
<i class="user-icon"></i>
</div>
<img *ngIf="user.imageUrl" alt="" class="avatar" height="30" width="30" src="{{user.imageUrl}}"/>
<strong title="{{user.user}}" (click)="openChatWindow(user, true)">{{user.name}}</strong>
</li>
</ul>
</div>
</div>
<div class="col-md-9 m-l">
<div *ngFor="let user of userInfo; let i = index">
<div>
<app-chatwindow [userInfo]="user" (onWindowCloseNotify)="onWindowCloseDeleteUserFromList($event)"></app-chatwindow>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I have attached screenshot of desired output :
Parent component should be:
Child component should be:
Current output:
Consider this example.
Parent should be floated to the right, as well as the childrens.
.chat {
float: right;
list-style: none;
}
.chat li {
width: 160px;
height: 200px;
background: red;
float: right;
margin-left: 10px;
}
<ul class="chat">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>

How to resize tab width automatically in HTML5

I want to automatically resize the container based on <div>. If there are 4 <div> inside container then it looks fine but if there is only 1 <div> then there will be plenty of space in right side. So wanted to adjust container size according to <div>. How can I achieve this? Please help me.
main page looks like this
When there are 4 panels it fits perfectly fine like this
When there are 2 panels then there is plenty of space in the right side which which is marked by color. I want to adjust the container width here automatically.
<div class="container">
<div class="row">
<div>
<ul class="nav nav-tabs" id="ATab">
<li class="active"><a data-toggle="tab" href="#Select">Select</a></li>
<li><a data-toggle="tab" href="#Criteria">Criteria</a></li>
</ul>
<div class="tab-content">
<div id="Select" class=" tab-pane fade in active"></div>
<div id="Criteria" class="tab-pane fade"></div>
<div class="container active col-md-3 col-sm-6 ">
<div class="panel panel-default">
<div class="panel-heading">First Name</div>
</div>
</div>
<div class="container active col-md-3 col-sm-6">
<div class="panel panel-default">
<div class="panel-heading">Last Name</div>
</div>
</div>
</div>
</div>
</div>
</div>
You can use flexbox for this behavior. Check this codepen for demo.
HTML:
<div class="parent">
<ul class="nav">
<li>Item 1</li>
<li>Item 1</li>
<li>Item 1</li>
<li>Item 1</li>
</ul>
</div>
CSS:
.parent {
background-color: orange;
}
.parent ul.nav {
list-style: none;
padding: 0px;
margin: auto;
display: flex;
}
.parent ul.nav li {
background-color: grey;
padding: 10px 15px;
border-right: 1px solid black;
width: 100%;
text-align: center;
}
.parent ul.nav li:last-child {
border: 0px;
}
Hope this would help!
EDIT 1:
Check this other codepen for demo.
body {
padding: 0px;
margin: 0;
}
.parent {
background-color: orange;
padding: 20px;
}
.parent .tabFrame .itemContainer {
display: inline-block;
margin-bottom: 50px;
padding: 5px;
border: 1px solid;
overflow: hidden;
}
.parent .tabFrame .myItem {
background-color: grey;
display: inline-block;
width: 100px; /* can be any fixed width */
padding: 10px;
color: white;
border: 1px solid black;
}
<div class="parent">
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
<div class="myItem">Item 2</div>
<div class="myItem">Item 3</div>
<div class="myItem">Item 4</div>
</div>
</div>
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
<div class="myItem">Item 2</div>
<div class="myItem">Item 3</div>
</div>
</div>
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
<div class="myItem">Item 2</div>
</div>
</div>
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
</div>
</div>
</div>
EDIT: 2
See this codepen
.myTab {
border: 1px solid #dddddd;
display: inline-block;
margin-top: -1px;
}
.myTab .tab-pane .myPanel {
display: inline-block;
margin: 10px;
}
.myPanel {
min-width: 200px;
}
#ATab {
border-bottom: 0px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div>
<ul class="nav nav-tabs" id="ATab">
<li class="active">
<a data-toggle="tab" href="#Select">Select</a>
</li>
<li>
<a data-toggle="tab" href="#Criteria">Criteria</a>
</li>
</ul>
<div class="tab-content clearfix myTab">
<br>
<div id="Select" class=" tab-pane fade in active clearfix">
<div class="panel panel-default myPanel">
<div class="panel-heading">First Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">Last Name</div>
</div>
</div>
<div id="Criteria" class="tab-pane fade">
<div class="panel panel-default myPanel">
<div class="panel-heading">First Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">Last Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">First Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">Last Name</div>
</div>
</div>
</div>
</div>
</div>
</div>
Try using css flexbox to get rid of unwanted spaces.
.nav {
display:flex;
}
a {
text-decoration: none;
color:white;
}
li {
background-color:#232323;
list-style-type: none;
padding: 20px;
flex: 1 1 auto;
}
li.active{
background-color:gray;
}
<div class="container">
<div class="row">
<div>
<ul class="nav nav-tabs" id="ATab">
<li class="active"><a data-toggle="tab" href="#Select">Select</a></li>
<li><a data-toggle="tab" href="#Criteria">Criteria</a></li>
</ul>
<div class="tab-content">
<div id="Select" class=" tab-pane fade in active"></div>
<div id="Criteria" class="tab-pane fade"></div>
</div>
</div>
</div>
</div>
The flex: 1 1 auto on the li makes the li fill up any remaining space on the main flex axis (horizontal line because the default flex direction is row)
You can read up on flex box :
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
https://css-tricks.com/almanac/properties/f/flex/

Resources