I don't know if it would be hard to explain but here it goes.. I have a number of divs on my page and I want them to come in a column layout. The page has a nav bar, a logo, some profile data and 3 more divs. Those 3 divs are not getting aligned correctly. I want those all three of them #content-1, #content-2, #content-3 in a horizontal manner in a straight line.
See this fiddle. Better to look here at the result.
CSS:
#CHARSET"ISO-8859-1";
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#container {
width: 100%;
}
#content {
margin-left: 10%;
}
#content-1, #content-2, #content-3 {
display: inline-block;
}
#content-1 {
width: 25%;
height: 100%;
}
#content-2 {
width: 50%;
height: 100%;
}
#content-3 {
width: 20%;
height: 100%;
}
.user_small_card p.name {
font-weight: bold;
}
.user_small_card p.profession {
margin-top: -10px;
}
.userWrap {
margin-bottom: 20px;
}
.user_card {
width: 77% !important;
margin-bottom: 10px;
}
.major_data {
width: 80%;
}
.major_data .profile_box p:first-child {
border-bottom: 0px;
text-align: center;
font-size: 20px;
background-color: #eee;
font-weight: bold;
}
.major_data .profile_box p:nth-child(2) {
text-align: justify;
padding-left: 5px;
padding-right: 5px;
margin-top: -20px;
}
.major_data .profile_box p {
border: 1px solid #bbb;
}
.commitment_box {
text-align: center;
height: 390px;
overflow: hidden;
background-color: lightblue;
color: white;
font-size: 20px;
width: 100%;
margin-right: 2%;
padding: 5px;
overflow-y: scroll;
}
.commitment_box .commitment p {
display: inline-block;
width: 100%;
}
.commitment_box .commitment p:first-child {
font-weight: bold;
}
#CHARSET"ISO-8859-1";
.userWrap {
position: relative;
width: 250px;
height: 50px;
overflow: visible;
z-index: 1;
}
.userWrap:hover {
z-index: 2;
}
.user {
position: absolute;
display: inline-block;
width: 200px;
height: 50px;
margin-bottom: 5px;
background: #fff;
transition: width 0.3s, height 0.3s, background-color 1s;
}
.user:hover {
width: 350px;
height: 200px;
transition: width 0.3s ease 0.5s, height 0.3s ease 0.5s, background-color 2.3s;
background: #eee;
}
.user img {
float: left;
}
.user .name, .skills {
margin-left: 5px;
}
.user .name {
font-size: 21px;
font-weight: bold;
}
.user_card {
background-color: #eee;
width: 38%;
padding: 10px;
display:table;
}
.user_card p {
display: table-cell;
vertical-align:top;
line-height:30px;
padding:2px 10px 2px 2px;
color: #aaa;
}
.user_card div {
display:table-row;
padding:2px;
}
.user_card div div {
display:table-cell;
}
.user_card div div.progress_wrap {
background-color: white;
width: 100%;
border: 1px solid #bbb;
}
.user_card div div.progress {
height: 30px;
background-color: #ddd;
}
HTML:
<div id="container">
<div id="content">
<div id="content-1">
<div id="content-1-1">
<div class="user_small_card">
<img src="img/user.png" width="150" height="150" />
<p class="name">Arkam Gadet</p>
<p class="profession">Photographer</p>
</div>
</div>
<div id="content-1-2">
<div id="people_worked_with">
<h2>People worked with</h2>
<div class="userWrap">
<div class="user">
<img src="img/user.png" width="50" height="50" /> <span class="name">Danish</span>
<br/> <span class="skills">Coder, Programmer</span>
</div>
</div>
<div class="userWrap">
<div class="user">
<img src="img/user.png" width="50" height="50" /> <span class="name">Danish</span>
<br/> <span class="skills">Coder, Programmer</span>
</div>
</div>
<div class="userWrap">
<div class="user">
<img src="img/user.png" width="50" height="50" /> <span class="name">Danish</span>
<br/> <span class="skills">Coder, Programmer</span>
</div>
</div>
<div class="userWrap">
<div class="user">
<img src="img/user.png" width="50" height="50" /> <span class="name">Danish</span>
<br/> <span class="skills">Coder, Programmer</span>
</div>
</div>
</div>
</div>
</div>
<div id="content-2">
<div id="content-2-1">
<div class="user_card">
<div class="skills">
<p>Skills</p>
<div class="progress_wrap">
<div class="progress" style="width:95%"></div>
</div>
</div>
<div class="commitment">
<p>Commitment</p>
<div class="progress_wrap">
<div class="progress" style="width:4%;"></div>
</div>
</div>
<div class="reputation">
<p>Reputation</p>
<div class="progress_wrap">
<div class="progress" style="width:5%;"></div>
</div>
</div>
</div>
</div>
<div id="content-2-2">
<div class="major_data">
<div class="profile_box">
<p>About</p>
<p>This is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about me</p>
</div>
<div class="profile_box">
<p>About</p>
<p>This is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about me</p>
</div>
<div class="profile_box">
<p>About</p>
<p>This is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about meThis is about me</p>
</div>
</div>
</div>
</div>
<div id="content-3">
<div id="content-3-1">
<div class="commitment_box">
<div class="commitment">
<p>Alex:</p>
<p>Lorizzle ipsum away fo shizzle daahng dawg, consectetizzle adipiscing elit. Nullam sapien velizzle, bow wow wow volutpizzle, crunk gizzle, gravida vizzle, arcu. Dope check it out for sure. Sed erizzle. Gangsta izzle dolor dapibizzle nizzle tempus black. Fo shizzle pellentesque nibh izzle dizzle. Crazy izzle tortizzle.</p>
</div>
<div class="commitment">
<p>Alex 1:</p>
<p>Vivamizzle nec we gonna chung egizzle nisi izzle pretium. Daahng dawg sizzle amet lacus. Uhuh ... yih! eu nizzle eget lacizzle auctizzle yo. Praesent gizzle viverra crunk. Curabitizzle ghetto arcu. Vestibulizzle enim uhuh ... yih!, the bizzle pimpin', congue , sheezy nizzle, libero. Nullam vitae pede rizzle</p>
</div>
<div class="commitment">
<p>Alex 2:</p>
<p>In sagittis leo stuff nisi. Shizzlin dizzle rhoncizzle, arcu check out this malesuada facilisizzle, dizzle nulla uhuh ... yih! shut the shizzle up, da bomb auctizzle cool felizzle a break yo neck, yall. Check out this volutpizzle fo shizzle mah nizzle fo rizzle, mah home g-dizzle augue. I saw beyonces tizzles and my pizzle went</p>
</div>
<div class="commitment">
<p>Alex 3:</p>
<p>crizzle yippiyo. Maecenizzle tortor vel fo. Phasellus lobortizzle. Shizzle my nizzle crocodizzle things gizzle, shiznit nec, mah nizzle sure amizzle, pulvinar egestizzle, crazy. Vivamus mofo. Vestibulizzle ante doggy primizzle izzle own yo' break yo neck, yall luctizzle yo mamma ghetto posuere that's the shizzle</p>
</div>
<div class="commitment">
<p>Alex 4:</p>
<p>Vestibulizzle shiznit ipsizzle primizzle black mofo orci its fo rizzle izzle ultricizzle posuere cool Curae; Sed vitae nulla quizzle ma nizzle ornare shiz. Phasellizzle get down get down da bomb. Praesent volutpizzle accumsan velizzle. Mammasay mammasa mamma oo sa mammasay mammasa m</p>
</div>
</div>
</div>
</div>
</div>
The problems:
First column is coming down a bit
Third column is coming down a bit
How can bring the first and third in a line with the second one?
make change into this line into css
#content-1, #content-2, #content-3 {
vertical-align: top;
}
Try adding float: left to #content-1 and float: right to #content-3
Add the following CSS:
#content-1 {
width: 25%;
height: 100%;
float: left;
}
#content-2 {
width: 50%;
height: 100%;
}
#content-3 {
width: 20%;
height: 100%;
float: right;
}
Update fiddle
i hope you are looking like this :- http://jsfiddle.net/wJ2ef/4/
With the using of float you can proper align your Div Elements
Or you can do it like this:
#content-1, #content-2, #content-3 {
display: table-cell;
vertical-align: top;
}
Change "display: inline-block;" to:
#content-1, #content-2, #content-3 {
float: left;
}
#content-1, #content-2, #content-3 {
display: table-cell;
}
Related
I could get the result I want in many other ways, but I want to understand if it is possible to fix the layout while keeping the grid system.
Check the result first to get a better understanding
$(document).ready(function() {
$('#opt1').on('click', function() {
$('.item').css('grid-template-columns', 'minmax(110px, 1fr) auto');
});
$('#opt2').on('click', function() {
$('.item').css('grid-template-columns', 'minmax(110px, 1fr) max-content');
});
$('#opt3').on('click', function() {
$('.item').css('grid-template-columns', 'auto 1fr');
});
});
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 25px 25px;
margin-top: 25px;
}
.item {
position: relative;
display: grid;
grid-template-columns: minmax(110px, 1fr) auto;
background-color: #2f3138;
color: #ffffff;
padding: 15px;
}
.description {
display: grid;
grid-template-rows: auto 25px;
}
.price {
width: 100%;
font-size: 22px;
line-height: 25px;
text-align: right;
}
/* styles not important */
.item::before {
position: absolute;
font-family: monospace;
font-size: 18px;
font-weight: bold;
color: #ffffff;
border-radius: 50%;
background-color: #000000;
width: 25px;
height: 25px;
line-height: 25px;
text-align: center;
border: solid 5px #2f3138;
top: -8px;
right: -8px;
}
.item:nth-child(1)::before {
content: "1";
}
.item:nth-child(2)::before {
content: "2";
}
.item:nth-child(3)::before {
content: "3";
}
.item:nth-child(4)::before {
content: "4";
}
input[type="button"] {
background-color: #000000;
border: solid 2px #2f3138;
color: #ffffff;
outline: none;
margin: 5px 15px 5px 0px;
padding: 5px 15px 8px 15px;
font-family: monospace;
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="opt1" type="button" value="Original: minmax(110px, 1fr) auto" />
<input id="opt2" type="button" value="option 2: minmax(110px, 1fr) max-content" />
<input id="opt3" type="button" value="option 3: auto 1fr" />
<div class="container">
<div class="item">
<img src="https://placeimg.com/100/120/any" />
<div class="description">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sit amet mauris semper, interdum lacus a, fermentum risus.
</span>
<div class="price">€ 3.33</div>
</div>
</div>
<div class="item">
<div class="description">
<span>Short Text</span>
<div class="price">€ 3.33</div>
</div>
</div>
<div class="item">
<img src="https://placeimg.com/100/121/any" />
<div class="description">
<span>Short Text</span>
<div class="price">€ 3.33</div>
</div>
</div>
<div class="item">
<div class="description">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sit amet mauris semper, interdum lacus a, fermentum risus.
</span>
<div class="price">€ 3.33</div>
</div>
</div>
</div>
The layout represents a list of items. The HTML is generated on the server side, and I can have an item with the image and an item without an image. My goal is to get all items with the text always left aligned and the price on the right.
The key is this grid-template-columns: minmax (110px, 1fr) auto; the text will be auto with the image and 1fr without image. It always occupies the space it needs, but in item 3 the text is short and space it needs is little, I would like it to extend as in item 1.
The javascript part to show some attempts that still generate non optimal results.
I hope I was clear.
Thank you
Rely on implicit grid creation. Define your template for the text and price only then an extra column will be created for the image if there:
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 25px;
margin-top: 25px;
}
.item {
position: relative;
display: grid;
grid-template-columns: 1fr;
grid-auto-columns: 110px; /* this is the width of the extra column */
background-color: #2f3138;
color: #ffffff;
padding: 15px;
}
img {
grid-column-end:-2; /* create an implicit column at the beginning */
}
.description {
display: grid;
grid-template-rows: auto 25px;
}
.price {
font-size: 22px;
line-height: 25px;
text-align: right;
}
/* styles not important */
.item::before {
position: absolute;
font-family: monospace;
font-size: 18px;
font-weight: bold;
color: #ffffff;
border-radius: 50%;
background-color: #000000;
width: 25px;
height: 25px;
line-height: 25px;
text-align: center;
border: solid 5px #2f3138;
top: -8px;
right: -8px;
}
.item:nth-child(1)::before {
content: "1";
}
.item:nth-child(2)::before {
content: "2";
}
.item:nth-child(3)::before {
content: "3";
}
.item:nth-child(4)::before {
content: "4";
}
input[type="button"] {
background-color: #000000;
border: solid 2px #2f3138;
color: #ffffff;
outline: none;
margin: 5px 15px 5px 0px;
padding: 5px 15px 8px 15px;
font-family: monospace;
cursor: pointer;
}
<div class="container">
<div class="item">
<img src="https://placeimg.com/100/120/any" />
<div class="description">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sit amet mauris semper, interdum lacus a, fermentum risus.
</span>
<div class="price">€ 3.33</div>
</div>
</div>
<div class="item">
<div class="description">
<span>Short Text</span>
<div class="price">€ 3.33</div>
</div>
</div>
<div class="item">
<img src="https://placeimg.com/100/121/any" />
<div class="description">
<span>Short Text</span>
<div class="price">€ 3.33</div>
</div>
</div>
<div class="item">
<div class="description">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sit amet mauris semper, interdum lacus a, fermentum risus.
</span>
<div class="price">€ 3.33</div>
</div>
</div>
</div>
I'm trying to implement list/grid toggle. I have the grid and I'm trying to toggle to list, so I'd like to show the images on the left side and the content on the right side.
HTML code:
<div class="card infinite-item">
<div class="img-dimension">
<img class="card-img-top" src="/media/category/img.jpeg" alt="Card image cap">
</div>
<div class="card-body">
<h5 class="card-title">idea 01</h5>
<div class="card-text">
<p>Phasellus a est. Nam eget dui. Pellentesque ut neque. Nunc sed turpis. Donec mi odio, faucibus at, scelerisque quis, convallis in, nisi.</p>
</div>
<div class="text-left pb-2 pt-2">
<a id="idea_detail_1" href="/idea/1/">Details...</a>
</div>
<div class="text-right card-icons">
<span class="badge badge-secondary">Discussion</span>
<a class="like badge">
like button
</a>
<a class="dislike badge">
dislike button
</a>
<a href="#" class="badge comments">
comments
</a>
</div>
</div>
<div class="card-footer">
footer
</div>
</div>
I didn't change the CSS, so it's the bootstrap default CSS code:
.card {
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}
.card-img-top {
width: 100%;
border-top-left-radius: calc(.25rem - 1px);
border-top-right-radius: calc(.25rem - 1px);
}
.card-body {
flex: 1 1 auto;
padding: 1.25rem;
}
.card-title {
margin-bottom: .75rem;
}
.card {
display: flex;
flex-direction: row;
align-items: center; /* optional */
}
You can change flex-direction: column to flex-direction: row in order to achieve your question.
.card-img-top {
width: 100%;
border-top-left-radius: calc(.25rem - 1px);
border-top-right-radius: calc(.25rem - 1px);
position: relative;
left: 0;
display: inline-block
}
.card-body {
flex: 1 1 auto;
padding: 1.25rem;
position: relative;
right: 0;
display: inline-block;
}
use column for this,for example:
<div class="row">
<div class="col-md-8">
------------your content here-------------
</div>
<div class="col-md-4">
------------your Image here---------------
</div>
</div>
I am using Bootstrap with a sticky footer and off-canvas menu. Sticky footer works fine on desktop view, but footer begins to overlap content on mobile view. I think it is due to the .row-offcanvas position being set to relative on mobile media query. If I remove the offcanvas menu the sticky footer works as expected on mobile devices. The other issue is when you scroll down in mobile view white space appears under the footer.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/master-simple.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row row-offcanvas row-offcanvas-left">
<header>
<div class="container">
<div class="row">
<div class="col-xs-4 headerLinks">
Coverage Details
<div id="drawerNavigationID" data-toggle="offcanvas" class="hidden-sm">
<span></span>
<span></span>
<span></span>
</div>
</div>
<div class="col-xs-4">
</div>
<div class="col-xs-4 text-right headerLinks">
<!-- Click to call on Mobile Device -->
Contact Us
</div>
</div>
</div>
</header>
<!-- Off Canvas Menu -->
<div class="container">
<div class="row">
<div class="col-sm-6 sidebar-offcanvas visible-xs">
<ul>
<li>Coverage Details</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</div>
<!-- Page Content -->
<div class="container mainWrapper">
<div class="row">
<div class="col-md-10 col-centered" id="confirmationWrapper">
<h2 class="noBorderBottom">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec laoreet tempor nisl, ut rutrum lacus vulputate vel.</h2>
<h3>CLAIM NUMBER: 12345678954</h3>
<p class="claimNumberText">Nulla libero enim, consequat at pulvinar eu, ultrices a risus.</p>
<p>Nulla libero enim, consequat at pulvinar eu, ultrices a risus. Mauris bibendum enim non magna maximus, non tempor lacus lacinia. Fusce vestibulum tincidunt vulputate. Suspendisse eu erat et neque facilisis consequat id in quam. Cras convallis massa at ornare hendrerit.</p>
<div class="row text-center">
Shop
</div>
</div>
</div>
</div><!-- End Page Content -->
<footer>
<div class="container">
<ul>
<li>Terms of Use | </li>
<li>Privacy Policy</li>
</ul>
<p>© 2015 ANulla libero enim</p>
</div>
</footer>
</div><!-- End Container-fluid Row -->
</div><!-- End Container-fluid -->
<script src="js/jquery-2.1.1.min.js"></script>
<script src="js/offcanvas.js"></script>
</body>
</html>
CSS:
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 196px;
}
* {
font-weight: normal!important;
margin: 0;
padding: 0;
outline: 0;
outline-style: none;
}
header {
font-family: 'aig_futura_medregular', aig_futura_medregular, Arial, Helvetica, sans-serif;
position: absolute;
top:0;
z-index: 100;
height: 92px;
width: 100%;
padding-top: 15px;
color: #fff;
background-color: rgba(0,164,228,0.9);
}
header a {
font-family: "aig_futuraregular", Arial, Helvetica, sans-serif;
font-size: 18px;
text-decoration: none;
text-transform: uppercase;
color: #fff!important;
}
header a:hover {
border-bottom: 1px solid #fff;
}
header .headerLogo {
width: 116px;
height: 63px;
cursor: pointer;
background: url(../img/aigLogo.png) no-repeat center bottom;
}
.headerLinks {
margin-top: 20px;
}
footer {
font-size: 14px;
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 186px;
padding: 40px 20px 20px;
color: #fff;
background-color: #252525;
}
footer ul {
margin: 0 0 20px;
padding: 0;
list-style: none;
}
footer ul li {
display: inline;
}
footer li a {
color:#fff;
}
.mainWrapper {
margin-top: 92px;
}
#media screen and (max-width:768px){
#drawerNavigationID{
padding-left: 10px;
}
#drawerNavigationID span {
display: block;
width: 25px;
height: 3px;
background: #fff;
margin-bottom: 7px;
}
.row-offcanvas {
position: relative;
bottom: 0;
min-height: 100vh;
-webkit-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
}
.row-offcanvas-left {
left: 0;
}
.row-offcanvas-left .sidebar-offcanvas {
left: -85%;
padding: 0 0 0 20px;
background-color: #54565b;
}
.row-offcanvas-left .sidebar-offcanvas ul li {
font-size: 18px;
padding: 15px;
text-transform: uppercase;
border-bottom: 1px solid #696b6f;
}
.row-offcanvas-left .sidebar-offcanvas a {
text-decoration: none;
color: #ffffff;
}
.row-offcanvas-left.active {
left: 85%;
}
.sidebar-offcanvas {
position: absolute;
top: 0;
bottom:0;
width: 85%;
}
}
<article style="max-width:500px;" class="post" id="post-<?php the_ID(); ?>">
<div class="circle">
<div class="month"><?php the_time(d) ?></div>
<div class="year"><?php the_time('M Y');?></div>
</div>
<div class="thot">
<h4><?php the_title(); ?></h4>
<?php the_excerpt('Read More'); ?>
<hr />
</div>
</article>
<style>
.circle {
height: 165px;
width: 165px;
display: table-cell;
text-align: center;
vertical-align: middle;
border-radius: 50%;
background: white;
color:black;
line-height:35px;
}
.month{
font-size:60px;
font-weight:bold;
}
.year{
font-size:20px;
}
</style>
What is the best way to move the "thot" div next to the "circle" div?
("Cirle") [POST aka "thot div"]
Link http://ramovamusic.com/?page_id=165
Example: ramovamusic.com/example.jpg
So now that I understand your question. The problem is you have a set width on your article tag (500px) this needs to be increased so you can float your class circle and class thot. that way they will be next to each other.
Here is a working demo as to what I am talking about New Demo Working
Notice I removed the width on the article, added float right and width to class thot and float left on the circle. And now they are on the same line. You need to fiddle with it a bit to align it to your linking.
html:
<article style="" class="post" id="post-171">
<div class="circle">
<div class="month">20</div>
<div class="year">Mar 2015</div>
</div>
<div class="thot">
<h4>test 2</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce tellus urna, mollis in nibh nec, fermentum rhoncus lacus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus ante arcu, laoreet ut efficitur vel, ornare sed risus. Cras eget interdum erat, finibus facilisis justo. Nam lorem mi, laoreet at dui non, rutrum semper felis. <a class="read-more" href="http://ramovamusic.com/?p=171">Read More</a></p>
<hr />
</div>
</article>
css:
.circle {
height: 165px;
width: 165px;
display: table-cell;
text-align: center;
vertical-align: middle;
border-radius: 50%;
background: red none repeat scroll 0% 0%;
color: #000;
line-height: 35px;
float:left;
}
.thot{
float:right;
width:60%;
}
Add float:left to your circle div and some right margin, and for the .date class, add:
.date {
transform: translateY(-50%);
width: 165px;
top: 50%;
position: relative;
}
for .thot class add:
.thot {
float:left;
width: 300px; /* or whatever width works for you */
}
and finally you need to clear floats:
.post:after {
content: '';
display: table;
clear:both;
}
Here you go, better to apply the circle in a span to keep all the text together! Otherwise it can end up getting tricky like you saw!
https://jsfiddle.net/75tn8yps/3/
div{
float:left;
}
span.circle{
border: 1px solid red;
border-radius: 100%;
width: 100px;
height: 100px;
display: inline-block;
margin-left: 10px;
line-height: 95px;
text-align:center;
}
p{
text-align:center;
margin-top:40px;
}
Demo In Fiddle
I did change few things in the CSS File
.circle {
height: 165px;
width: 165px;
display: table-cell;
text-align: center;
vertical-align: middle;
color:white;
border-radius: 50%;
background: black;
color:black;
position:absolute;
}
.month{
font-size:40px;
font-weight:bold;
color:white;
line-height:90px;
}
.year{
font-size:20px;
color:white;
line-height:60px;
}
.thot{
border:1px solid black;
float:right;
width: calc(100% - 180px);
height:200px;
position:relative;
}
The new CSS. Check The fiddle.
I am trying to use this effect that positions a triangle at the bottom of a div on the block of code below, but I'm not sure if it's because of the nested divs or the section tag, I can not get it to work.
This is what I am trying to achieve: (This is a PNG I mocked up)
However, I am currently seeing this (jsfiddle link):
http://jsfiddle.net/hTp6y/
The HTML:
<div class="entry-content">
<section class="vc_section_wrapper has_bg_color">
<div class="bg-layer" style="background-color: rgb(114, 114, 255); height: 347px;" data-inertia="0.1">
</div>
<div class="wpb_row row-fluid">
<div class="span12 wpb_column column_container">
<div class="wpb_wrapper">
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nec odio ac lectus mattis pellentesque vel eu erat. Aliquam a libero non quam molestie interdum in ut urna.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="vc_section_wrapper has_bg_color">
<div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
</div>
<div class="wpb_row row-fluid">
<div class="span12 wpb_column column_container">
<div class="wpb_wrapper">
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<p>Interdum et malesuada fames ac ante ipsum primis in faucibus. In varius posuere elit, nec ultrices ligula posuere in. Vestibulum ut sollicitudin eros, et vestibulum magna. .</p>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
The CSS:
.vc_section_wrapper .bg-layer {
position: absolute;
width: 100%;
height: 100%;
left: 0;
}
.vc_section_wrapper.has_bg_color > .wpb_row, .vc_section_wrapper.has_bg_img > .wpb_row {
padding-top: 40px;
position: relative;
}
.triangle-down{
width: 2.5%;
height: 0;
padding-left:2.5%;
padding-top: 2.5%;
overflow: hidden;
position: absolute;
left:0;right:0;
margin:auto;
top: 100px;
z-index:1;
}
.triangle-down:before {
content: '';
display: block;
width: 0;
height: 0;
margin-left:-50px;
margin-top:-50px;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 50px solid pink;
}
I don't know if this is solely a CSS change, I have doubts over if I have placed this line of code in the correct place:
<div class="triangle-down"></div>
You can replace it here:
<div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
<div class="triangle-down"></div>
</div>
And rewrite top:100% to top:0 in class triangle-down.
http://jsfiddle.net/hTp6y/1/
I would go about this a little different.
The div that contains the triangle,
Place position: relative; on it, then you can just use top: 100%; to get the triangle right at the bottom.
css:
.tri {
border-top: 20px solid gold;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
height: 0;
width: 0;
top: 100%;
left: 50%;
margin-left: -10px;
position: absolute;
}
Fiddle: Demo
I think that the other answers are correct. But I think this is a good chance to use a css after class to clean up your html and simplify things. Example fiddle.
html:
<div class="wrapper">
<div class="top"></div>
<div class="bottom"></div>
</div>
css:
.top:after{
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -15px;
border-top: 20px solid lightgray;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
}