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>
Related
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 :)
I have an html5 video tag with a div that has a text caption overlayed and when you scroll in chrome, the text div disappears as it gets near the top or bottom of the screen fold. Sometimes it's as its nearing the top of the screen, sometimes the bottom. I think it depends where the video is on the screen when it's refreshed.
Anyone know what is causing this? I think this is pretty barebones markup.
codepen: https://codepen.io/sharpdesigner/pen/KRgQZZ
screen capture of the issue: https://imgur.com/a/Hn8DWkP
html
<section id="video-landing" class="hide-mobile">
<div class="container">
<div class="row">
<div class="col-md-6 video-caption">
<h1>Lorem ipsum dolor sit</h1>
<p class="big">Quisque varius erat et</p>
<p>Vivamus aliquam lectus est. Nulla vitae fringilla felis. Aenean id elit sit amet sem mattis bibendum eu a felis. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
</div>
</div>
</div> <!-- /container -->
<video muted autoplay="autoplay" loop="loop" id="bgvid">
<source src="http://www.mysportresume.com/phone.mp4" type="video/mp4" />
</video>
</section><!-- #section -->
css
body {
height: 2000px;
margin-top: 500px;
}
.container {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
section#video-landing, section#video-landing-mobile {
background: url('../images/video-bg.jpg') no-repeat 0 -175px;
background-size: cover;
}
section#video-landing .row, section#video-landing-mobile .row {
margin: 0;
position: relative;
}
.video-caption {
position: absolute;
max-width: 550px;
top: 165px;
top: 8.5vw;
left: 0;
z-index: 99;
}
.video-caption h1, .video-caption p {
color: #000;
text-align: left;
}
.video-caption h1 {
font-size: 53px;
font-weight: 600;
}
.video-caption p.big {
margin: 0 0 30px;
max-width: 400px;
}
.video-caption p {
font-size: 17px;
}
p.big {
color: #000;
font-size: 27px !important;
font-weight: 300;
line-height: 1.5;
max-width: 850px;
margin: 0 auto;
}
video {
padding-top: 50%;
position: absolute;
top: 50%;
left: 0;
-webkit-transform: translateY(-50%);
transform: translateY(-55%);
width: 100%;
}
#video-landing, #video-landing-mobile {
width: 100%;
padding-bottom: 30%;
position: relative;
overflow: hidden;
color: white;
}
#video-landing .container, #video-landing-mobile .container {
max-width: 1140px;
}
#video-landing video, #video-landing-mobile video {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
}
Good day,
I'm not new to CSS or DIVs but have been out of touch for long enough. Trying to work out with Containers and nested DIVs but not getting much success in doing what I'm trying to do. Have already searched enough on SO and Goog but, hopefully you can help me.
Here's the representation of what I wish to achieve.
Screenshot of the layout
And here is what I have done so far ..
.dealsglobal {
width: 45%;
display: inline-block;
float: left;
margin-right:20px;
height: auto;
overflow: auto;
}
.dealsglobal h2 {
margin-left: 10px;
}
.dealsindia {
width: 45%;
height: auto;
overflow: auto;
}
.dealsindia h2 {
margin-left: 10px;
}
.dealsleft {
margin: 0px 25px 10px 0px;
padding: 5px;
border: 1px solid #ccc;
height: auto;
position: relative;
width: 40%;
float: left;
display: inline-block;
overflow: auto;
}
.dealsleft img {
border: 1px solid #ddd;
background: #fff;
border-radius: 4px;
margin-left: auto;
margin-right: auto;
width: 100px;
}
.dealsright {
margin-bottom: 10px;
padding: 5px;
border: 1px solid #ccc;
height: auto;
position: relative;
width: 40%;
display: inline-block;
overflow: auto;
}
<div class="dealsglobal">
<h2>Global Coupons</h2>
<div class="dealsleft">
<img src="thumb-heavengifts.jpg" alt="HeavenGifts.com Web Store" align="middle" />
</div>
<div class="dealsright">
Test
</div>
</div>
<div class="dealsindia">
<h2>Indian Coupons</h2>
<div class="dealsleft">
Test
</div>
<div class="dealsright">
Test
</div>
</div>
The image just wont center, no matter what I do. I believe, somewhere I have set the property to align left or something. Can anyone please point me to the correct direction? Thanks for your help!
I changed your code a little bit, but you'll get idea :
Here is html :
<div class="container">
<div class="left">
<h2 class="inner-text">title</h2>
<div class="image">
<img src="http://via.placeholder.com/350x150" />
</div>
<h5 class="inner-text">description</h5>
</div>
<div class="right">
<h2 class="inner-text">title</h2>
<div class="image">
<img src="http://via.placeholder.com/350x150" />
</div>
<h5 class="inner-text">description</h5>
</div>
<div style="clear: both" />
</div>
And here is the css:
.container{
width: 98%;
border: 2px solid #f00;
padding: 10px;
}
.left {
width: 47%;
float: left;
margin: 0 1% 0 1%;
border: 1px solid green;
}
.right {
width: 47%;
float: left;
margin: 0 1% 0 1%;
border: 1px solid green;
}
.inner-text{
text-align:center;
}
.image{
padding: 20px;
}
.image img{
max-width: 100%;
}
Check here jsfiddle.
You missed adding this css property:
.dealsleft {
text-align:center;
}
You can center elements inside a div by using text-align:center; for all the text elements like: h1, p, h2, a etc. To center an img or a div inside another div you can use margin: 0 auto; the auto is the important part for centering the left and right margins.
More info here
i've updated your code snippet.
.dealsglobal {
width: 45%;
display: inline-block;
float: left;
margin-right:20px;
height: auto;
overflow: auto;
}
.dealsglobal h2 {
margin-left: 10px;
}
.dealsindia {
width: 45%;
height: auto;
overflow: auto;
}
.dealsindia h2 {
margin-left: 10px;
}
.dealsleft {
margin: 0px 25px 10px 0px;
padding: 5px;
border: 1px solid #ccc;
height: auto;
position: relative;
width: 40%;
float: left;
display: inline-block;
overflow: auto;
text-align: center;
}
.dealsleft img {
border: 1px solid #ddd;
background: #fff;
border-radius: 4px;
margin: 5px auto;
width: 100px;
}
.dealsright {
margin-bottom: 10px;
padding: 5px;
border: 1px solid #ccc;
height: auto;
position: relative;
width: 40%;
display: inline-block;
overflow: auto;
text-align: center;
}
<div class="dealsglobal">
<h2>Global Coupons</h2>
<div class="dealsleft">
<img src="thumb-heavengifts.jpg" alt="HeavenGifts.com Web Store" align="middle" />
</div>
<div class="dealsright">
Test
</div>
</div>
<div class="dealsindia">
<h2>Indian Coupons</h2>
<div class="dealsleft">
Test
</div>
<div class="dealsright">
Test
</div>
</div>
I have added background colors for visualization purposes.
* {
box-sizing: border-box;
}
#container {
width: 100%;
padding: 10px;
background-color: red;
display: flex;
justify-content: space-between;
}
.subcontainer-outer {
width: 49%;
background-color: green;
}
.subcontainer {
width: 100%;
background-color: blue;
display: flex;
justify-content: space-between;
}
.content {
width: 45%;
text-align: center;
background-color: yellow;
}
<h3>Container</h3>
<div id="container">
<div class="subcontainer-outer">
<h4>Sub container 1</h4>
<div class="subcontainer">
<div class="content">
<img src="http://placehold.it/100" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="content">
<img src="http://placehold.it/100" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
<div class="subcontainer-outer">
<h4>Sub container 2</h4>
<div class="subcontainer">
<div class="content">
<img src="http://placehold.it/100" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="content">
<img src="http://placehold.it/100" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
</div>
You can get it by using flex below an example as your requirement.
.dealsglobal {
width: 48%;
margin-right: 10px;
height: auto;
float: left;
}
.flex {
display: flex;
justify-content: flex-start;
align-items: center;
flex-flow: row nowrap;
border: 1px solid red;
padding: 10px;
}
.dealsglobal h2 {
margin-left: 10px;
}
.dealsindia h2 {
margin-left: 10px;
}
.dealsleft {
margin: 0px 25px 10px 0px;
padding: 5px;
border: 1px solid #ccc;
flex: 1 0 0;
align-self: flex-start;
}
.dealsleft img {
border: 1px solid #ddd;
background: #fff;
border-radius: 4px;
margin-left: auto;
margin-right: auto;
width: 100%;
}
.dealsright {
margin-bottom: 10px;
padding: 5px;
border: 1px solid #ccc;
overflow: auto;
flex: 1 0 0;
align-self: flex-start;
}
<div class="dealsglobal">
<h2>Global Coupons</h2>
<div class="flex">
<div class="dealsleft">
<img src="http://lorempixel.com/400/200/sports/" alt="HeavenGifts.com Web Store" align="middle" />
</div>
<div class="dealsright">
Test
</div>
</div>
</div>
<div class="dealsglobal">
<h2>Global Coupons</h2>
<div class="flex">
<div class="dealsleft">
<img src="http://lorempixel.com/400/200/sports/" alt="HeavenGifts.com Web Store" align="middle" />
</div>
<div class="dealsright">
Test
</div>
</div>
</div>
Here is working fiddle
fiddle
You are probably looking for any of these 2:
parentSelector {
display: block; /* can also be an inline-block, with set width */
text-align: center;
}
childSelector {
width: 60%; /* generic. Change it */
display: block;
margin: 0 auto;
}
... or:
parentSelector {
display: flex;
flex-direction: column;
align-items: center;
}
childSelector {
max-width: 60%; /* optional. Change it.
* You don't need to set width here and,
* it's OK not to limit max-width, either
*/
}
If we add direction: rtl; in CSS then word-wrap and word-break styles are not working. How we can solve this issue in Pure CSS?
Note: I need to support browsers IE9+ and chrome
#container {
height: 440px;
width: 150px;
left: 40%;
top: 20%;
border: 2px solid green;
margin: 0 auto;
}
#leftDiv{
width: 70px;
float: left;
word-wrap: break-word;
overflow: hidden;
line-height: 20px;
height: 20px;
}
#centreDiv{
width: 10px;
float: left;
}
#rightDiv{
//word-wrap: break-word;
width: 70px;
float: right;
direction: rtl;
overflow: hidden;
line-height: 20px;
height: 20px;
}
<div id="container">
<div id='leftDiv'>
Java121HTML121HTML121Javscript121
</div>
<div id='centreDiv'>
...
</div>
<div id='dummy'>
<div id='rightDiv'>
Java121HTML121HTML121Javscript121
</div>
</div>
If you uncomment right div word break will change
It seems to be working, below is the running code and attached screenshot.
div{
direction: rtl;
max-width: 600px;
border: 1px solid black;
word-wrap: break-word;
}
<div>
<h1>Lorem ipsum dolor sit amet, consecteturasdasdasdasdasdasdasdasdasdasdasdasdasdasd adipiscing elit. Quisque sagittis consequat augue, eget euismod quam ultricies at. Donec venenatis, turpis.</h1>
</div>
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;
}