I have the following view : https://jsfiddle.net/jcrqhqLq/
I'd like to align the "Add to cart" buttons to the bottom of their container, so the buttons of every plans are all horizontally aligned, but I can't manage to do it. I tried to add position: absolute; bottom 0; on the buttons, but it breaks the container.
How can I do it ?
Try by adding this in your code
.pricing-table .plan{position:relative;}
li.plan-feature:last-child {
min-height: 65px;
}
li.plan-feature:last-child a {
bottom: 10px;
display: block;
left: 0;
margin-left: auto;
margin-right: auto;
position: absolute;
right: 0;
width: 95px;
}
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.pricing-table .plan {
background-color: #f3f3f3;
border-radius: 5px;
box-shadow: 0 0 6px 2px #b0b2ab;
text-align: center;
height: 100%;
}
.pricing-table .plan:hover {
background: #fff;
box-shadow: 0 0 12px 3px #b0b2ab;
}
.pricing-table .plan .plan-name {
background-color: #5e5f59;
border-radius: 5px 5px 0 0;
color: #fff;
padding: 20px;
}
.pricing-table .plan:hover .plan-name {
background: #4e9a06;
}
.pricing-table .plan .plan-name span {
font-size: 20px;
}
.pricing-table .plan ul {
border-radius: 0 0 5px 5px;
list-style: outside none none;
margin: 0;
padding: 0;
}
.pricing-table .plan h2 {
margin: 10px 0;
}
.pricing-table .plan ul li.plan-feature {
border-top: 1px solid #c5c8c0;
padding: 15px 10px;
}
.pricing-table .plan ul li.plan-feature .plan-feature-description {
margin: 0;
color: #777;
font-size: .9em;
}
.pricing-table .plan{position:relative;}
li.plan-feature:last-child {
min-height: 65px;
}
li.plan-feature:last-child a {
bottom: 10px;
display: block;
left: 0;
margin-left: auto;
margin-right: auto;
position: absolute;
right: 0;
width: 95px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row row-eq-height pricing-table">
<div class="col-xs-12 col-md-4">
<div class="plan">
<div class="plan-name">
<h2>Plan #1</h2>
<span>24.90 €</span>
</div>
<ul>
<li class="plan-feature">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt, urna et hendrerit rutrum, dui eros efficitur massa, at mattis justo tortor eget nisl.</li>
<li class="plan-feature">
Feature #1
<p class="plan-feature-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</li>
<li class="plan-feature">Add to cart</li>
</ul>
</div>
</div>
<div class="col-xs-12 col-md-4">
<div class="plan">
<div class="plan-name">
<h2>Plan #2</h2>
<span>39.90 €</span>
</div>
<ul>
<li class="plan-feature">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt, urna et hendrerit rutrum, dui eros efficitur massa, at mattis justo tortor eget nisl.</li>
<li class="plan-feature">
Feature #1
<p class="plan-feature-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</li>
<li class="plan-feature">
Feature #2
<p class="plan-feature-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</li>
<li class="plan-feature">Add to cart</li>
</ul>
</div>
</div>
</div>
You can adjust the padding in your css code to put the buttons at the bottom:
.pricing-table .plan ul li.plan-feature {
border-top: 1px solid #c5c8c0;
padding: 15px 10px 0 10px;
}
Related
The following code snippet displays some headlines, with some icons floated on the left. The parent div has a defined height, with scroll:auto set.
Currently, scrolling to the bottom looks like this:
However, I'd like to clip off the icons when the text entries end, so when scrolling to the bottom, it looks like this:
The reason for the use of float is so that when there are not many icons, the text flows like this:
.parent {
position: absolute;
height: 100px;
width: 400px;
overflow: scroll;
}
.content {
background-color: cyan;
padding: 6px;
}
.icon {
float: left;
clear: both;
background-color: lightpink;
width: 38px;
height: 38px;
margin-right: 8px;
margin-bottom: 6px;
}
.entry {
font-size: 18px;
}
<div class="parent">
<div class="content">
<img class="icon">
<img class="icon">
<img class="icon">
<img class="icon">
<div class="entry">Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>
<div class="entry">Quisque eleifend viverra risus, nec maximus nisi vestibulum eu</div>
<div class="entry">Mauris in libero lacus</div>
</div>
</div>
Just smack a overflow: clip on your .content along with the sexy overflow-clip-margin: content-box.
Note on overflow-clip-margin: Safari doesn't support it (yet). Quick edit: Firefox has some issues with overflow-clip-margin's visual-box property too. My bad!
Without it, the images are still clipped but without caring about your .content padding. Shouldn't be an issue if your text isn't actually behind a cyan background-color; it's hard to tell on a white background.
.parent {
position: absolute;
height: 100px;
width: 400px;
overflow: scroll;
}
.content {
background-color: cyan;
padding: 6px;
overflow: clip;
overflow-clip-margin: content-box;
}
.icon {
float: left;
clear: both;
background-color: lightpink;
width: 38px;
height: 38px;
margin-right: 8px;
margin-bottom: 6px;
}
.entry {
font-size: 18px;
}
<div class="parent">
<div class="content">
<img class="icon">
<img class="icon">
<img class="icon">
<img class="icon">
<div class="entry">Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>
<div class="entry">Quisque eleifend viverra risus, nec maximus nisi vestibulum eu</div>
<div class="entry">Mauris in libero lacus</div>
</div>
</div>
.parent {
position: absolute;
height: 100px;
width: 400px;
overflow: scroll;
}
.content {
background-color: cyan;
padding: 6px 6px 0 6px;
overflow: hidden;
position: relative;
border-bottom: 8px solid cyan; /* same color */
}
.icons,
.entries {
display: flex;
flex-direction: column;
}
.icons {
position: absolute;
top: 8px;
left: 8px;
}
.entries {
margin-left: 56px; /* icon width '38' + icon left '8' and right '8' distance */
}
.icon {
background-color: lightpink;
width: 38px;
height: 38px;
margin-bottom: 6px;
}
.entry {
font-size: 18px;
}
<div class="parent">
<div class="content">
<div class="icons">
<img class="icon">
<img class="icon">
<img class="icon">
<img class="icon">
</div>
<div class="entries">
<div class="entry">Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>
<div class="entry">Quisque eleifend viverra risus, nec maximus nisi vestibulum eu</div>
<div class="entry">Mauris in libero lacus</div>
</div>
</div>
</div>
Why does my dropdown hide really fast? I must hover quickly to my sub dropdown to make the dropdown still display.
I think my problem was on the select but I don't know how to implement it.
Here is my code:
body {
font-family: Verdana, Geneva, sans-serif;
padding: 0;
margin: 0;
}
.ic {
font-weight: bold;
margin-right: 5px;
font-size: .9rem;
}
.wrap {
background-color: black;
}
#topbar {
overflow: hidden;
padding: 0;
width: 1200px;
height: 50px;
margin: auto;
text-transform: uppercase;
font-size: .8rem;
}
.nospace {
color: white;
}
li {
margin: 15px;
}
li.left {
float: left;
list-style: none;
}
li.right {
float: right;
list-style: none;
}
li a {
text-decoration: none;
color: aqua;
}
#banner {
background: url(bg1.jpg) no-repeat center;
height: 600px;
background-size: 1650px;
opacity: 0.7;
font-family: 'Forum', cursive;
font-size: 20px;
}
ul li {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
nav li {
position: relative;
}
.menubar {
width: 1200px;
margin: auto;
display: block;
}
.menubar a {
padding: 10px;
color: black;
}
.menubar a:hover {
color: blue;
}
.drop-nav {
position: relative;
}
.drop-nav:after {
content: "\25BC";
font-size: .5em;
display: block;
position: absolute;
top: 40%;
right: 1%;
}
#content {
padding: 0;
display: none;
height: 0px;
z-index: 1;
}
#content a {
color: white;
border-bottom: 1px solid black;
background-color: rgba(0,0,0,0.5);
text-decoration: none;
display: block;
text-align: center;
}
#content a:hover {
background-color: aqua;
}
li:hover ul#content {
display: block;
position: absolute;
top: 25px;
left: 0px;
width: 120px;
visibility: visible;
}
.wrap01 {
height: 60px;
border-bottom: 1px solid gray;
}
.isi{
width: 1200px;
margin: auto;
text-align: center;
padding: 20px;
}
.boxutama{
width: 1200px;
margin: auto;
padding: 20px;
}
.boxkecil{
display: inline-block;
width: 360px;
margin: auto;
text-align: center;
padding: 15px;
}
i{
color: blue;
}
.boxkecil a{
text-decoration: none;
}
.boxkedua{
overflow: hidden;
height: 180px;
background-color: black;
font-family: 'Forum', cursive;
}
.isi2{
color: white;
width: 1200px;
margin: auto;
display: block;
}
.spanleft{
float: left;
width: 50%;
padding: 20px;
padding-left: 100px;
margin: auto;
}
.spanright{
float: right;
padding: 20px;
padding-right: 100px;
margin: auto;
line-height: 138px;
}
.btn1{
margin: auto;
border: 1px solid blue;
text-transform: uppercase;
padding: 10px;
text-decoration: none;
font-family: Verdana, Geneva, sans-serif;
}
.boxketiga{
overflow: hidden;
width: 1200px;
padding: 20px;
margin: auto;
margin-top: 20px;
}
.one_half_first{
float: left;
padding: 20px;
}
.one_half{
padding: 20px;
float: right;
width: 49%;
text-align: left;
}
.gambarcontoh{
width: 480px;
height: 400px;
padding: 20px;
border: 1px solid #D7D7D7;
}
.tanggal{
margin: 0px;
padding: 0px;
font-size: .8rem;
}
.heading{
margin-top: 5px;
}
.boxkeempat{
font-family: 'Forum', cursive;
background-color: black;
height: 220px;
}
.isi3{
width: 1200px;
margin: auto;
display: block;
text-align: center;
}
.atas {
color: white;
padding: 20px;
padding-top: 20px;
}
.atas h3{
font-weight: bold;
font-size: 20px;
}
.bawah{
padding-top: 20px;
}
.btn2{
border: 1px solid white;
text-transform: uppercase;
padding: 10px;
color: white;
text-decoration: none;
font-family: Verdana, Geneva, sans-serif;
}
.boxkelima{
}
.wraplima{
width: 1500px;
margin: auto;
padding: 20px;
margin-top: 10px;
display: block;
text-align: center;
font-family: Georgia,"Times New Roman",Times,serif;
}
.isikotak{
width: 250px;
margin: auto;
margin: 0 15px;
display: inline-block;
font-family: 'Forum', cursive;
font-size: 13px;
}
.kotakfoto{
margin-top: 20px;
border: 1px solid #D7D7D7;
}
img.foto{
padding: 15px;
max-width: 220px;
max-height: 320px;
-webkit-filter: sepia(100%);
filter: sepia(100%);
}
.kotakkcl{
padding: 5px;
position: relative;
display: block;
left: 37%;
width: 157px;
margin: -55px;
background-color: white;
border: 1px solid #d7d7d7;
}
.kotakkcl h3, p{
margin: auto;
}
.boxfooter{
background: url(bg11.jpg);
}
.boxfooter a{
text-decoration: none;
color: white;
}
.ovlay{
background-color: rgba(0,0,0,0.7);
}
.boxf1{
width: 1200px;
margin: auto;
}
.boxatas1{
text-align: center;
color: white;
font-family: 'Forum', cursive;
padding-top: 40px;
margin-bottom: 60px;
}
.grup{
width: 1200px;
margin: auto;
margin-top: 10px;
}
.dalam1{
display: inline-block;
text-align: center;
margin: 10.3px
}
.icon{
position: absolute;
left: 295px;
top: 2759px;
}
.icon i::before{
padding: 20px;
background: linear-gradient(to top right,#000,#666);
border-radius: 50%;
border:1px solid white;
}
.icon i{
color: white;
border-radius: 50%;
padding: 20px;
}
.dalam{
color: white;
padding: 20px;
padding-top: 40px;
border: 1px solid white;
width: 233px;
}
.footermenu{
margin: auto;
margin-top: 20px;
background-color: rgba(0,0,0,.5);
}
.menufooter{
width: 1200px;
margin: auto;
text-align: center;
padding: 20px;
}
.menufooter a{
padding: 0 20px;
text-decoration: none;
border-left: 1px solid white;
text-align: center;
margin: 0, 5px;
}
.footerbawah{
overflow: hidden;
width: 1000px;
margin: auto;
padding: 20px;
color: white;
}
p.left {
float: left;
}
p.right {
float: right;
}
<!DOCTYPE html>
<html>
<head>
<title>New DPW</title>
<link href="new1.css" rel="stylesheet" type="text/css" media="all">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Forum" rel="stylesheet">
</head>
<body>
<div class="Halaman">
<div class="wrap">
<div id="topbar">
<div class="nospace">
<li class="left"><span class="ic">☏</span> +00 (123) 456 7890</li>
<li class="left"><span class="ic">✉</span> info#pajak.go.id</li>
<li class="right">Tentang</li>
<li class="right">Kontak</li>
<li class="right">Login</li>
<li class="right">Register</li>
<li class="right"><i class="fa fa-home"></i></li>
</div>
</div>
</div>
<div id="banner">
<div class="wrap01">
<nav class="menubar">
<li class="left">Sistem Pemberkasan Gudang</li>
<li class="right">Peraturan</li>
<li class="right"></li>
<li class="right"><a class="drop-nav" href="#">Pajak</a>
<ul id="content">
Pajak Bangunan
Pajak Penghasilan
Pajak Kendaraan
Pajak Perdagangan
</ul>
</li>
<li class="right"><a class="drop-nav" href="#">Halaman</a>
<ul id="content">
Artikel
zero 1
</ul>
</li>
<li class="right">Rumah</li>
</nav>
</div>
</div>
<div class="wrapmain">
<main class="utama">
<div class= "isi">
<h3>Risus sed justo tinciduntt</h3>
<p>Cras dapibus ipsum vel eleifend commodo eros tortor imperdiet elit eget molestie nisi lectus.</p>
</div>
<div class="boxutama">
<div class="boxkecil">
<article><i class="fa fa-cubes" style="font-size: 200%;"></i>
<h6>Pellentesque libero</h6>
<p>A molestie dictum nullam vitae augue nulla phasellus et eleifend mi etiam odio dictum…</p>
<footer>Read More »</footer>
</article>
</div>
<div class="boxkecil">
<article><i class="fa fa-css3" style="font-size: 200%;"></i>
<h6>Pellentesque libero</h6>
<p>A molestie dictum nullam vitae augue nulla phasellus et eleifend mi etiam odio dictum…</p>
<footer>Read More »</footer>
</article>
</div>
<div class="boxkecil">
<article><i class="fa fa-dashcube" style="font-size: 200%;"></i>
<h6>Pellentesque libero</h6>
<p>A molestie dictum nullam vitae augue nulla phasellus et eleifend mi etiam odio dictum…</p>
<footer>Read More »</footer>
</article>
</div>
<div class="boxkecil">
<article><i class="fa fa-database" style="font-size: 200%;"></i>
<h6>Pellentesque libero</h6>
<p>A molestie dictum nullam vitae augue nulla phasellus et eleifend mi etiam odio dictum…</p>
<footer>Read More »</footer>
</article>
</div>
<div class="boxkecil">
<article><i class="fa fa-desktop" style="font-size: 200%;"></i>
<h6>Pellentesque libero</h6>
<p>A molestie dictum nullam vitae augue nulla phasellus et eleifend mi etiam odio dictum…</p>
<footer>Read More »</footer>
</article>
</div>
<div class="boxkecil">
<article><i class="fa fa-dropbox" style="font-size: 200%;"></i>
<h6>Pellentesque libero</h6>
<p>A molestie dictum nullam vitae augue nulla phasellus et eleifend mi etiam odio dictum…</p>
<footer>Read More »</footer>
</article>
</div>
</div>
</main>
</div>
<div class="boxkedua">
<div class="isi2">
<div class="spanleft">
<H3>Pajak Negara Indonesia</H3>
Pajak adalah pungutan wajib yang dibayar rakyat untuk negara dan akan digunakan untuk kepentingan pemerintah dan masyarakat umum</div>
<div class="spanright">
<a class="btn1" href="#">More Information »</a>
</div>
</div>
</div>
<div class="boxketiga">
<div class="one_half_first"><img class="gambarcontoh" src="bg1.jpg" alt=""></div>
<div class="one_half">
<p class="tanggal">Tanggal, 22 Juli 2018</p>
<h3 class="heading">Venenatis erat nunc lorem</h3>
<p>Sed pharetra non sollicitudin nec libero curabitur dapibus ex non viverra scelerisque arcu nisl dignissim enim in lacinia dolor libero id urna duis sodales dignissim enim.</p>
<blockquote>Interdum integer vestibulum venenatis justo id vulputate mi curabitur ac odio sed diam ullamcorper pulvinar proin tristique odio non suscipit venenatis magna enim convallis arcu vitae blandit turpis</blockquote>
<p>Sed pharetra non sollicitudin nec libero curabitur dapibus ex non viverra scelerisque arcu nisl dignissim enim in lacinia dolor libero id urna duis sodales dignissim enim. asfasjkfjkahsjhfjhasj asklfkjaskljfkjaisdfiwe sdkjfkjsdkljiieghwe kjdkfjsidigiosg kasdjklfjkajdklgjioae lasjklfjliajew9fqe ioajsdijiljadg9 ladkjlkgj lkajs fl aksklklfjklajsfioaw asjksjafj asfkjasjfh uasfuiqwio. askljlasjlkfjkasf askljfkljalksjfqowjf eklsdlklisod pfawp fawoifpoiawpoif paw fpawf aw ofoaw f poawpo fpoawipfi iawo weokoriweirpoaiskfokasopifpwea okd po foasofkpoaifpow pojfowifpaw pof.</p>
<footer>Read More »</footer>
</div>
</div>
<div class="boxkeempat">
<div class="isi3">
<div class="atas">
<h3>Pajak Negara Indonesia</h3>
<p>Pajak adalah pungutan wajib yang dibayar rakyat untuk negara dan akan digunakan untuk kepentingan pemerintah dan masyarakat umum.</p>
</div>
<div class="bawah">
<a class="btn2" href="#">Sudahkah Anda Membayar Pajak..?</a>
</div>
</div>
</div>
<div class="boxkelima">
<div class="wraplima">
<h3>CREATOR OF THIS WEBSITE</h3>
<p>Berikut adalah seluruh anggota yang membuat web sederhana ini</p>
<div class="isikotak">
<div class="kotakfoto">
<img class="foto" src="maya.jpg" alt="">
</div>
<div class="kotakkcl">
<p style="color: blue; font-size: 1.2em;">Staff</p>
<h3>M Bima Sakti Admaja</h3>
<p>150411100080</p>
</div>
</div>
<div class="isikotak">
<div class="kotakfoto">
<img class="foto" src="maya.jpg" alt="">
</div>
<div class="kotakkcl">
<p style="color: blue; font-size: 1.2em;">Staff</p>
<h3>M Bima Sakti Admaja</h3>
<p>150411100080</p>
</div>
</div>
<div class="isikotak">
<div class="kotakfoto">
<img class="foto" src="maya.jpg" alt="">
</div>
<div class="kotakkcl">
<p style="color: blue; font-size: 1.2em;">Staff</p>
<h3>M Bima Sakti Admaja</h3>
<p>150411100080</p>
</div>
</div>
<div class="isikotak">
<div class="kotakfoto">
<img class="foto" src="maya.jpg" alt="">
</div>
<div class="kotakkcl">
<p style="color: blue; font-size: 1.2em;">Staff</p>
<h3>M Bima Sakti Admaja</h3>
<p>150411100080</p>
</div>
</div>
</div>
</div>
<div class="boxfooter">
<div class="ovlay">
<div class="boxf1">
<div class="boxatas1">
<h2 class="heading" style="margin-bottom: 10px; text-transform: capitalize;" >dui eu laoreet aenean non</h2>
<p>dapibus lacus phasellus quis ligula ut libero venenatis scelerisque</p>
</div>
<div class="grup">
<div class="dalam1">
<div class="icon"><i class="fa fa-phone fa-lg"></i></div>
<div class="dalam">
<div>+62 (009) 340 9549</div>
<div>1 (500) 200</div>
</div>
</div>
<div class="dalam1">
<div class="icon" style="left: 588px;"><i class="fa fa-envelope-o fa-lg"></i></div>
<div class="dalam">
<div>www.pajak.go.id</div>
<div>#DitjenPajakRI</div>
</div>
</div>
<div class="dalam1">
<div class="icon" style="left: 893px;"><i class="fa fa-clock-o fa-lg"></i></div>
<div class="dalam">
<div>Sen-Jum: 8.00 - 2.00</div>
<div>Sabtu: 9.00 - 1.00</div>
</div>
</div>
<div class="dalam1">
<div class="icon" style="left: 1194px;"><i class="fa fa-support fa-lg"></i></div>
<div class="dalam">
<div>Online Support</div>
<div>Live Chat</div>
</div>
</div>
</div>
</div>
<div class="footermenu">
<div class="menufooter">
<i class="fa fa-home fa-lg" style="color: white"></i>
TENTANG
KONTAK
PERATURAN
</div>
</div>
<div class="footerbawah">
<p class="left">Copyright © 2018 - All Rights Reserved - Domain Name</p>
<p class="right">Powered by :Trunojoyo.ac.id</p>
</div>
</div>
</div>
</div>
</body>
</html>
The reason why the sub menu closes too quickly is that you have a small gap between the main menu button and the sub menu so the mouse detects its rolled out of the sub menu button and closes.
just increase the size of the main menu buttons and that should do it :)
This is a follow on from my other post but with a different problem.
I have three CSS labels with text next to each one.
How can I stop the large block of text from jumping down to the next line?
I need the text to start next to the label (same as the colored examples underneath with short amount of text) and then wrap down to the next line once it runs out of space.
.list {
margin: 0;
padding: 0;
list-style-type: none;
}
.list li {
margin-bottom: 10px;
}
.list li > div:first-child{
position: relative;
border-left: 1px solid #fff;
margin-right: 10px;
}
.list li > div{
display: inline-block;
}
.triangle, .triangle2 {
display: block;
position: absolute;
top: 0;
right: -10px;
height: 0;
width: 0;
border-top: 15px solid transparent;
border-left: 10px solid #eee;
border-bottom: 15px solid transparent;
z-index: 1;
}
.triangle2 {
border-left-color: white;
left: 0;
}
.label {
letter-spacing: 1px;
line-height: 30px;
padding: 0 20px 0 30px;
text-decoration: none;
cursor: default;
}
.neutral {
background: #F5F4F9;
}
.neutral .triangle{
border-left: 10px solid #F5F4F9;
}
.neutral .label {
color: #999;
}
.positive {
background: #DFF0D8;
}
.positive .triangle{
border-left: 10px solid #DFF0D8;
}
.positive .label {
color: #468847;
}
.negative {
background: #F2DEDE;
}
.negative .triangle {
border-left: 10px solid #F2DEDE;
}
.negative .label {
color: #b94a48;
}
<ul class="list">
<li>
<div class='neutral'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div class="label-value">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sagittis ipsum tellus, dignissim rhoncus nulla vestibulum ut. Curabitur blandit vitae orci a dignissim. Proin viverra risus velit, sed eleifend odio tincidunt in. Vivamus eu malesuada tortor. Maecenas eleifend faucibus arcu. Phasellus mollis.
</div>
</li>
<li>
<div class='positive'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
<li>
<div class='negative'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
</ul>
Remove the div around the text and it'll wrap around the label automagically.
As a bonus, add a bottom margin to .list li > div to push the new line down a bit more if it looks too close to the label.
.list {
margin: 0;
padding: 0;
list-style-type: none;
}
.list li {
margin-bottom: 10px;
}
.list li > div:first-child{
position: relative;
border-left: 1px solid #fff;
margin-right: 10px;
}
.list li > div{
display: inline-block;
}
.triangle, .triangle2 {
display: block;
position: absolute;
top: 0;
right: -10px;
height: 0;
width: 0;
border-top: 15px solid transparent;
border-left: 10px solid #eee;
border-bottom: 15px solid transparent;
z-index: 1;
}
.triangle2 {
border-left-color: white;
left: 0;
}
.label {
letter-spacing: 1px;
line-height: 30px;
padding: 0 20px 0 30px;
text-decoration: none;
cursor: default;
}
.neutral {
background: #F5F4F9;
}
.neutral .triangle{
border-left: 10px solid #F5F4F9;
}
.neutral .label {
color: #999;
}
.positive {
background: #DFF0D8;
}
.positive .triangle{
border-left: 10px solid #DFF0D8;
}
.positive .label {
color: #468847;
}
.negative {
background: #F2DEDE;
}
.negative .triangle {
border-left: 10px solid #F2DEDE;
}
.negative .label {
color: #b94a48;
}
<ul class="list">
<li>
<div class='neutral'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sagittis ipsum tellus, dignissim rhoncus nulla vestibulum ut. Curabitur blandit vitae orci a dignissim. Proin viverra risus velit, sed eleifend odio tincidunt in. Vivamus eu malesuada tortor. Maecenas eleifend faucibus arcu. Phasellus mollis.
</li>
<li>
<div class='positive'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
<li>
<div class='negative'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
</ul>
A solution with flexbox:
add display: flex; align-items: flex-start; on your li element.
add flex: none on the first child of your li element.
If you want to center the text you can add a litte padding-top on your second child
See https://developer.mozilla.org/en-US/docs/Web/CSS/flex for further explanations how flex works.
Note : flex works on IE10 and higher, but you need to add the -ms- prefix for IE10.
.list {
margin: 0;
padding: 0;
list-style-type: none;
}
.list li {
margin-bottom: 10px;
display: flex;
align-items: flex-start;
}
.list li > div:first-child{
position: relative;
border-left: 1px solid #fff;
margin-right: 10px;
flex: none;
padding-top : 0;
}
.list li > div{
display: inline-block;
padding-top : 6px;
}
.triangle, .triangle2 {
display: block;
position: absolute;
top: 0;
right: -10px;
height: 0;
width: 0;
border-top: 15px solid transparent;
border-left: 10px solid #eee;
border-bottom: 15px solid transparent;
z-index: 1;
}
.triangle2 {
border-left-color: white;
left: 0;
}
.label {
letter-spacing: 1px;
line-height: 30px;
padding: 0 20px 0 30px;
text-decoration: none;
cursor: default;
}
.neutral {
background: #F5F4F9;
}
.neutral .triangle{
border-left: 10px solid #F5F4F9;
}
.neutral .label {
color: #999;
}
.positive {
background: #DFF0D8;
}
.positive .triangle{
border-left: 10px solid #DFF0D8;
}
.positive .label {
color: #468847;
}
.negative {
background: #F2DEDE;
}
.negative .triangle {
border-left: 10px solid #F2DEDE;
}
.negative .label {
color: #b94a48;
}
<ul class="list">
<li>
<div class='neutral'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div class="label-value">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sagittis ipsum tellus, dignissim rhoncus nulla vestibulum ut. Curabitur blandit vitae orci a dignissim. Proin viverra risus velit, sed eleifend odio tincidunt in. Vivamus eu malesuada tortor. Maecenas eleifend faucibus arcu. Phasellus mollis.
</div>
</li>
<li>
<div class='positive'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
<li>
<div class='negative'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
</ul>
You can use "float: left" to wrap your div (note that I moved your label), but maybe there are some more modern approaches
.list {
margin: 0;
padding: 0;
list-style-type: none;
}
.list li {
margin-bottom: 10px;
}
.list li > div:first-child{
position: relative;
border-left: 1px solid #fff;
margin-right: 10px;
}
.list li > div{
display: inline-block;
}
.triangle, .triangle2 {
display: block;
position: absolute;
top: 0;
right: -10px;
height: 0;
width: 0;
border-top: 15px solid transparent;
border-left: 10px solid #eee;
border-bottom: 15px solid transparent;
z-index: 1;
}
.triangle2 {
border-left-color: white;
left: 0;
}
.label {
letter-spacing: 1px;
line-height: 30px;
padding: 0 20px 0 30px;
text-decoration: none;
cursor: default;
}
.neutral {
background: #F5F4F9;
}
.neutral .triangle{
border-left: 10px solid #F5F4F9;
}
.neutral .label {
color: #999;
}
.positive {
background: #DFF0D8;
}
.positive .triangle{
border-left: 10px solid #DFF0D8;
}
.positive .label {
color: #468847;
}
.negative {
background: #F2DEDE;
}
.negative .triangle {
border-left: 10px solid #F2DEDE;
}
.negative .label {
color: #b94a48;
}
<ul class="list">
<li>
<div class="label-value">
<div class='neutral' style="float: left">
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sagittis ipsum tellus, dignissim rhoncus nulla vestibulum ut. Curabitur blandit vitae orci a dignissim. Proin viverra risus velit, sed eleifend odio tincidunt in. Vivamus eu malesuada tortor. Maecenas eleifend faucibus arcu. Phasellus mollis.
</div>
</li>
<li>
<div class='positive'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
<li>
<div class='negative'>
<span class="triangle2"></span>
<span class="label">some text</span>
<span class="triangle"></span>
</div>
<div>
Some other text
</div>
</li>
</ul>
I'm trying to make my footer to be always displayed on the bottom of the page when there is no enough content. I've tried several solutions but none of them worked. Also, there is a small issue with the dropdown menu - the text moves when I hover over this component. What should I change in my CSS? Thanks!
$(document).ready(function(){
$('li').hover(function(){
$(this).find('ul>li').stop().slideToggle(250);
});
});
body {
font-family: 'Roboto Condensed', sans-serif;
font-size: 18px;
color: #333;
}
p {
padding: 10px;
}
#navigation ul {
margin: 0;
padding: 0;
width: auto;
list-style-type: none;
text-align: center;
display: inline-block;
}
#navigation {
text-align: center;
}
#navigation ul li {
float: left;
font-weight: bold;
font-size: 20px;
line-height: 40px;
text-align: center;
text-shadow: 1px 1px 1px #000;
width: 140px;
}
#navigation ul li:hover {
background: #9D9FA4;
border-radius: 10px;
}
ul li a {
text-decoration: none;
color: #FFFFFF;
}
ul li li {
background: #3F61A9;
color: #fff;
display: none;
}
ul li li:hover {
background: #9D9FA4;
}
ul li li a{
text-decoration: none;
color: #fff;
}
#wrapper {
margin: 0 auto;
width: 1000px;
}
#headerwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
#header {
height: 125px;
background: #000000;
border-radius: 10px;
border: 1px solid #000000;
margin: 5px;
position: relative;
}
#navigationwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
#navigation {
height: 40px;
background: #52bf6e;
border-radius: 10px;
border: 1px solid #3ea858;
margin: 5px;
}
#contentwrap {
width: 700px;
float: left;
margin: 0 auto;
}
#content {
background: #FFFFFF;
border-radius: 10px;
margin: 5px;
}
#leftcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#leftcolumn {
border-radius: 10px;
margin: 5px;
}
#rightcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#rightcolumn {
border-radius: 10px;
margin: 5px;
}
#footerwrap {
width: 1000px;
float: left;
margin: 0 auto;
clear: both;
}
#footer {
height: 40px;
background: #9D9FA4;
border-radius: 10px;
border: 1px solid #888a91;
margin: 5px;
background-color: #9D9FA4;
text-align: center;
color: #FFFFFF;
font-weight: bold;
}
#navigationwrap_placeholder {
display:none;
height: 40px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="wrapper">
<div id="headerwrap">
<div id="header">
</div>
</div>
<div id="navigationwrap">
<div id="navigation">
<ul>
<li>main menu</li>
<li><a>test</a>
<ul class="sub-menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="navigationwrap_placeholder"></div>
<div id="leftcolumnwrap">
<div id="leftcolumn">
<p></p>
</div>
</div>
<div id="contentwrap">
<div id="content">
<br><br>
<p>Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. </p>
<br><br>
</div>
</div>
<div id="rightcolumnwrap">
<div id="rightcolumn">
<p></p>
</div>
</div>
<div id="footerwrap">
<div id="footer">
</div>
</div>
</div>
</body>
</html>
You need to use position:fixed to put the footer at the bottom of the page.
#footerwrap {
width: 1000px;
margin: 0 auto;
position: fixed;
bottom:0;
}
As for the text shifting slideToggle seems to be shifting the padding of the test list item. By setting the padding in the style itself it fixes the problem.
<li ><a style="padding:0 38%">test</a>
Here is a working snippet that solves your navigation issue. I added comments in the CSS so you can better understand what changes I made. I used some flex-box to fix the issue. Super simple. As for the footer, there are lots of ways you can achieve this so I will post a link to an article that shows you 5 different ways to do it and you can pick whichever one works best for your use case. Hope this helps :)
P.S. As a side note, I noticed in your markup that you had a class called sub-menu which is not being used in your CSS. Not a big deal just thought I'd point it out. You probably have plans for it later on.
Here are some footer options
$(document).ready(function() {
$('li').hover(function() {
$(this).find('ul>li').stop().slideToggle(250);
});
});
body {
font-family: 'Roboto Condensed', sans-serif;
font-size: 18px;
color: #333;
}
p {
padding: 10px;
}
/* removed display property as it was not needed
display inline-block was causing the nav item to shift over*/
#navigation ul {
margin: 0;
padding: 0;
width: auto;
list-style-type: none;
}
#navigation {
text-align: center;
}
#navigation ul li {
float: left;
font-weight: bold;
font-size: 20px;
line-height: 40px;
text-align: center;
text-shadow: 1px 1px 1px #000;
width: 140px;
}
#navigation ul li:hover {
background: #9D9FA4;
border-radius: 10px;
}
ul li a {
text-decoration: none;
color: #FFFFFF;
}
ul li li {
background: #3F61A9;
color: #fff;
display: none;
}
ul li li:hover {
background: #9D9FA4;
}
ul li li a {
text-decoration: none;
color: #fff;
}
#wrapper {
margin: 0 auto;
width: 1000px;
}
#headerwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
#header {
height: 125px;
background: #000000;
border-radius: 10px;
border: 1px solid #000000;
margin: 5px;
position: relative;
}
#navigationwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
/* Added display flex to container with
justify-content center to keep nav items aligned*/
#navigation {
height: 40px;
background: #52bf6e;
border-radius: 10px;
border: 1px solid #3ea858;
margin: 5px;
display: flex;
justify-content: center
}
#contentwrap {
width: 700px;
float: left;
margin: 0 auto;
}
#content {
background: #FFFFFF;
border-radius: 10px;
margin: 5px;
}
#leftcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#leftcolumn {
border-radius: 10px;
margin: 5px;
}
#rightcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#rightcolumn {
border-radius: 10px;
margin: 5px;
}
#footerwrap {
width: 1000px;
float: left;
margin: 0 auto;
clear: both;
}
#footer {
height: 40px;
background: #9D9FA4;
border-radius: 10px;
border: 1px solid #888a91;
margin: 5px;
background-color: #9D9FA4;
text-align: center;
color: #FFFFFF;
font-weight: bold;
}
#navigationwrap_placeholder {
display: none;
height: 40px;
}
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="wrapper">
<div id="headerwrap">
<div id="header">
</div>
</div>
<div id="navigationwrap">
<div id="navigation">
<ul>
<li>main menu</li>
<li><a>test</a>
<ul class="sub-menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="navigationwrap_placeholder"></div>
<div id="leftcolumnwrap">
<div id="leftcolumn">
<p></p>
</div>
</div>
<div id="contentwrap">
<div id="content">
<br>
<br>
<p>Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices.
Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. </p>
<br>
<br>
</div>
</div>
<div id="rightcolumnwrap">
<div id="rightcolumn">
<p></p>
</div>
</div>
<div id="footerwrap">
<div id="footer">
</div>
</div>
</div>
</body>
</html>
I've been struggling with this for a while and couldn't find the right solution.
At the bottom of the page I've a footer that's full width. Inside it I want to display I list of messages and right next to its left an icon, in this case it's a Font Awesome icon.
The message list needs to be centered both vertically and horizontally and the icon has to be centered vertically.
I've tried doing this using ul elements with display: inline-block and text-align: center.
The messages displays correctly but the icon is stuck in the same place no matter the size of its container.
Here's what I've so far:
<div class="error-message-container">
<ul class="error-message-bell">
<li aria-hidden="true" class="fa fa-bell-slash-o"></li>
</ul>
<ul class="error-message-list">
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
<li>consectetur adipiscing elit</li>
<li>Lorem ipsum dolor sit amet</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
<li>Lorem</li>
<li>ipsum</li>
</ul>
</div>
and the css:
.error-message-container {
border: 1px solid blue;
bottom: 0;
color: light-blue;
font-size: 12px;
left: 0;
position: fixed;
text-align: center;
width: 100%;
}
.error-message-container .error-message-bell {
display: inline-block;
font-size: 20px;
height: 100%;
margin-top: 0;
padding: 0;
vertical-align: middle;
}
.error-message-container .error-message-list {
display: inline-block;
font-weight: 500;
line-height: 1.2;
list-style-type: none;
margin-bottom: 11px;
margin-top: 11px;
padding-left: 8px;
}
https://jsfiddle.net/b1rw80jz/1/
Does anyone know how can I accomplish this?
Thanks
If you need only one icon, you can use pseudo-elements::before for the bell
.error-message-container {
border: 1px solid blue;
bottom: 0;
color: light-blue;
font-size: 12px;
left: 0;
position: fixed;
text-align: center;
width: 100%;
}
.error-message-container .error-message-list {
display: inline-block;
font-weight: 500;
line-height: 1.2;
list-style-type: none;
margin-bottom: 11px;
margin-top: 11px;
padding-left: 8px;
position: relative; /** this provides reference to the ::before element **/
}
.error-message-list::before {
content: "\f1f6"; /** refers to awesome font **/
font-family: FontAwesome; /** refers to awesome font **/
position: absolute; /** this will stick to error-message-list **/
top: 50%; /** this will position the icon 50% height of the error-message-list **/
margin-top: -10px; /** minus half the icon height to truely vertically centered **/
left: -20px; /** this will push it to the left out the error-message-list **/
}
https://jsfiddle.net/b1rw80jz/6/
You could use flex-box like this:
+CSS
.error-message-container {
border: 1px solid blue;
bottom: 0;
color: light-blue;
font-size: 12px;
left: 0;
position: fixed;
text-align: center;
width: 100%;
}
.error-message-container .error-message-bell {
display: inline-block;
font-size: 20px;
height: 100%;
margin: 0;
padding: 0;
}
.error-message-container .error-message-list {
display: inline-block;
font-weight: 500;
line-height: 1.2;
list-style-type: none;
margin-bottom: 11px;
margin-top: 11px;
padding-left: 8px;
}
.center {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-flow: row wrap;
justify-content: center;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
align-items: center;
}
+HTML
<div class="error-message-container center">
<ul class="error-message-bell center">
<li aria-hidden="true" class="fa fa-bell-slash-o"></li>
</ul>
<ul class="error-message-list">
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
<li>consectetur adipiscing elit</li>
<li>Lorem ipsum dolor sit amet</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
<li>Lorem</li>
<li>ipsum</li>
</ul>
</div>
Demo
You could add line-height: 5; vertical-align: top; to .error-message-container .error-message-bell.
Fiddle: https://jsfiddle.net/b1rw80jz/1/
Try to change the .error-message-list display to block and add margin-bottom: -5px; to .error-message-bell instead of margin-top
https://jsfiddle.net/b1rw80jz/3/
HTML
<div class="error-message-container">
<div class="inner-container">
<ul class="error-message-bell">
<li aria-hidden="true" class="fa fa-bell-slash-o"></li>
</ul>
<ul class="error-message-list">
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
<li>consectetur adipiscing elit</li>
<li>Lorem ipsum dolor sit amet</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
<li>Lorem</li>
<li>ipsum</li>
</ul>
</div>
</div>
CSS
.inner-container{margin: 0 auto;
display: inline-block;}
.error-message-container .error-message-bell {
display: table-cell;
font-size: 20px;
height: 100%;
margin: 0 auto;
padding: 0;
vertical-align: middle;}
.error-message-container .error-message-list {
display: table-cell;
font-weight: 500;
line-height: 1.2;
list-style-type: none;
margin-bottom: 11px;
margin-top: 11px;
padding-left: 8px;}
Font-Awesome already does it for you by using the <i> element and nesting it within your <li>. Refer to documentation. BTW, I put a DANGER! icon in just for the hell of it.
<li><i class="fa fa-bell-slash-o" aria-hidden="true"></i> ERROR!</li>
FIDDLE