Align elements at bottom of div - html

I want each button "Read more" of each div to be aligned in the same level (and in this case at the bottom of the div). The problem is that I don't want to give a specific height to the divs and neither change any markup or style.
I could use a bunch of pseudo class selectors but I would like to keep the code simple and maybe there's a simpler way.
Here's the working fiddle
.btn{
display: inline-block;
font-family: 'Oswald', sans-serif;
font-weight: 400px;
padding: 5px 10px;
border: 2px solid #1AC4F8;
color: #1AC4F8;
cursor: pointer;}

Flexbox can do that.
It will set all the columns to equal height and tell the button to be at the bottom of each column.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
*::before,
*::after {
box-sizing: border-box;
}
.row {
display: flex;
}
#services {
background-color: rgb(265, 265, 265);
color: #424242;
}
#services .col-3 {
text-align: left;
float: none;
display: flex;
flex: 0 0 25%;
padding: 10px;
flex-direction: column;
}
#sevices h3 {
margin: 10px 0
}
.btn {
margin-top: auto;
display: inline-block;
font-family: 'Oswald', sans-serif;
font-weight: 400px;
padding: 5px 10px;
border: 2px solid #1AC4F8;
color: #1AC4F8;
cursor: pointer;
-webkit-transition: color 0.8s, background-color 0.8s;
transition: color 0.8s, background-color 0.8s
}
<section id="services">
<!-- Services Starts Here -->
<div class="wrapper">
<h2>SERVICES</h2>
<div class="divider"></div>
<div class="row">
<div class="col-3">
<h3>Consulting and audit</h3>
<p>Get help to accelerate your company online from our highly experienced specialists. It is as good as it sounds!</p>
Read more
</div>
<div class="col-3">
<h3>Web Development</h3>
<p>Professional custom e-commerce and web design to let your business grow at a rapid pace. See how we do that.</p>
Read more
</div>
<div class="col-3 right-align">
<h3>Search Engine Optimization</h3>
<p>Want to be on Page 1 of Google and Bing? Read about our SEO services that drive more potential customers.</p>
Read more
</div>
<div class="col-3 right-align">
<h3>Pay Per Click Management</h3>
<p>Attract highly relevant audience with Google Adwords, Display, Retargeting, Facebook, YouTube, Twitter.</p>
Read more
</div>
</div>
</div>
</section>

Assuming I've understood you correctly, I've made the following amendments:
.btn{
display: inline-block;
font-family: 'Oswald', sans-serif;
font-weight: 400px;
padding: 5px 10px;
border: 2px solid #1AC4F8;
color: #1AC4F8;
cursor: pointer;
-webkit-transition: color 0.8s, background-color 0.8s;
transition: color 0.8s, background-color 0.8s;
position: absolute;
bottom: 0px;
}
.wrapper {
position: relative;
}
added position: absolute; to your btn class
added bottom: 0px to compliment the position (again to the btn class)
added position: relative; to a wrapper class so btn knows what it is positioning itself within.
You may need to update your existing CSS to adjust to the changes.
Updated Fork:
https://jsfiddle.net/exaboofu/

One solution entails using flexbox and absolute positioning:
https://jsfiddle.net/aLbu6frL/6/
.row {
display: flex;
flex-direction: row;
padding-bottom:40px;
}
.column {
flex: 0 0 auto;
position: relative;
}
.btn-bottom {
position: absolute;
bottom: -40px;
left: 0px;
right: 0px;
text-align:center;
}

Please add some more CSS in your existing and your button align with bottom please look below CSS code:
#services .right-align h3, #services .right-align p{
text-align: right;
}
#services .right-align .btn{
text-align:left;
}
.btn{
bottom: 0;
position:absolute;
}

You can set p tag a min-height. I just try it and it work's for me see sample code below. You can set p tag height based on your need.
#services .row .col-3 p {
width: 100%;
height: 300px;
}

Related

Adding custom HTML with dedicated CSS Styling to existing theme on Wordpress

I've created a bit of custom code, as my friends wanted a cool hovering effect on their homepage. Since I'm quite the newbie, I was really proud I could create this flexbox-based container from scratch (granted, with a bit of help from a youtube tutorial). Now I'm struggling to integrate this in the existing blockstructure of my theme. I'm running neve as a theme, and want to replace the uppermost block (which is now simply holding a background image) with my custom HTML, styled with my custom CSS. I'm certain this should be possible, and am convinced that it's something rather simple that I'm just not getting at the moment. Please haelp a brother out. For reference, this is the site i'm trying to customize: www.thenewport.org (it's just about the frontpage picture I'm trying to replace, the one with the 5 buildings).
Here's the element I made myself: https://codepen.io/janstanna/pen/VwmKNNJ
html:
<div class ="box-zeeland" > Zeeland </div>
<div class ="box-normandie" > Normandy </div>
<div class ="box-roffa" > Rotterdam </div>
<div class ="box-Valencia" > Valencia </div>
<div class ="box-Adam" > Amsterdam </div>
<div class ="overlay" > </div>
</div> </span>
CSS:
*{
padding: 0px;
margin: 0px;
box-sizing:border-box;
}
.container{
width: 100%;
height: 1066px;
padding: 0px;
margin-top: 100px auto;
display: flex;
background; #ddd;
font-family: Helvetica;
color: white;
vertical-align: bottom;
justify-content: bottom;
align-self: flex-end;
}
.overlay {
border: 2px #ddd;
z-index: 10;
font-size: 90px;
position: absolute;
left: 300; top: 300; right: 300; bottom: 300;
/* top: 0; left: 0; */
/* width: 100%; height: 100%; */
/* display: -webkit-flex; */
/* flex-align: center; flex-pack: center; */
/* display: block; */
/* clear: both; */
background: rgba(0,0,0,0.0);
text-align: center;
color: white;
font-family: Helvetica;
font-weight: 600px;
}
.box-zeeland {
height: 100%;
padding: 0px;
background-image: url(https://elnuevopuerto.org/wp-content/uploads/2021/01/Zeeland_header_The_New_Port_Verdonkerd.jpg);
border: 3px solid #ddd;
font-size: 30px;
flex:1;
transition: 1s;
text-align: center;
align-self: flex-end;
order: 3;
}
.box-zeeland:hover{
flex:3;
background-image: url(https://elnuevopuerto.org/wp-content/uploads/2021/01/Zeeland_648x1066_DARK.jpg);
order: 3;
}
.box-normandie {
height: 100%;
padding: 0px;
background-image: url(https://elnuevopuerto.org/wp-content/uploads/2021/01/LNP_648_DARK.jpg);
border: 3px solid #ddd;
font-size: 30px;
flex:1;
transition: 1s;
text-align: center;
align-self: flex-end;
order: 1;
}
.box-normandie:hover{
flex:2;
background-image: url(https://lenouveauport.org/wp-content/uploads/2021/02/IMG_0037.jpg)
order: 1;
}
.box-roffa{
height: 100%;
padding: 0px;
background-image:url(https://elnuevopuerto.org/wp-content/uploads/2021/01/rotterdam_Website_warmer_324_Verdonkerd.jpg);
border: 3px solid #ddd;
font-size: 30px;
flex:1;
transition: 1s;
text-align: center;
order:2;
}
.box-roffa:hover {
flex:3;
background-image: url(https://elnuevopuerto.org/wp-content/uploads/2021/01/rotterdam_Website_warmer_648_DARK.jpg);
order: 2;
}
.box-Valencia{
height: 100%;
padding: 0px;
background-image: url(https://elnuevopuerto.org/wp-content/uploads/2021/01/ElNuveopuerto_Header_Valencia_324_Verdonkerd.jpg);
border: 3px solid #ddd;
font-size: 30px;
flex:1;
transition: 1s;
text-align: center;
order: 4;
}
.box-Valencia:hover {
flex:3;
background-image: url(https://elnuevopuerto.org/wp-content/uploads/2021/01/ElNuveopuerto_Header_Valencia_648_DARK.jpg);
order: 4;
}
.box-Adam{
height: 100%;
padding: 0px;
background-image:url(https://elnuevopuerto.org/wp-content/uploads/2021/01/DNPAMS001_324x1066_header_Verdonkerd.jpg);
border: 3px solid #ddd;
font-size: 30px;
flex:1;
transition: 1s;
text-align: center;
order: 5;
}
.box-Adam:hover{
flex:3;
background-image: url(https://elnuevopuerto.org/wp-content/uploads/2021/01/DNPAMS001_648_Header_DARK.jpg);
order: 5;
}
</style>```
I hope someone can help me, I've been stuck for a couple of days now! Thank in advance!
I have just tried running your code on a fresh WordPress install with the Neve theme installed.
Its all working correctly, except do not use .container as a class for the flex box, instead use something like .container-flex.
.container is already assigned to some HTML in the Neve theme.
I was unable to gain access to the site you want to use this on. But if you just need to add this onto a page, use the Custom HTML block, paste in your HTML code and save the page.
<span> <div class ="container-flex">
<div class ="box-zeeland" > Zeeland </div>
<div class ="box-normandie" > Normandy </div>
<div class ="box-roffa" > Rotterdam </div>
<div class ="box-Valencia" > Valencia </div>
<div class ="box-Adam" > Amsterdam </div>
<div class ="overlay" > </div>
</div> </span>
Then click on Customize > Additional CSS, and paste your CSS code in there and click Publish. Then your code should work as intended.

Buttons doesnt show side by side above image

Here is a snippet of my Project Code:
body {
height: 100%;
margin: 0;
padding: 0;
font-family: 'Montserrat', sans-serif;
font-size: 16px;
}
input, button {
font-family: 'Montserrat', sans-serif;
}
.img_main_container {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.btn_sign_up, .btn_login:hover {
background: #5d8ffc;
color: #fff;
border: 1px solid #5d8ffc;
border-radius: 5px;
display: block;
width: 300px;
height: 40px;
transition: 0.3s;
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
}
.btn_login, .btn_sign_up:hover {
background-color: Transparent;
background-repeat:no-repeat;
color: #ffffff;
border-radius: 5px;
display: block;
width: 300px;
height: 40px;
cursor:pointer;
overflow: hidden;
outline:none;
transition: 0.3s;
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
}
<!DOCTYPE html>
<html>
<body>
<div class="img_main_container">
<img src="https://natgeo.imgix.net/subjects/headers/ND%20header%20(1).jpg?auto=compress,format&w=1920&h=960&fit=crop" alt="Storm" style="width:100%;">
<div class="centered">
<button class="btn_sign_up">Sign up</button>
<button class="btn_login">Login</button>
</div>
</div>
</body>
</html>
Everything works as you can see. But I want that the two buttons are side by side like this in that image here:
I tried so many examples but nothing worked. And I still can't figure out what's wrong here. It would be great if anyone could help. Thanks in advance. :)
Since you are using display:block on your buttons (.btn_sign_up, .btn_login), you can't make two buttons side by side, because block covering whole horizontal section.
Instead of this use display:inline-block and you will have buttons side by side.
More information you can get on the W3Schools
Flexbox would be a good solution for this. Add display: flex to the .centered class. This will place direct children of .centered side by side.
.centered {
display: flex;
}
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Use Flexbox for this issue.This is the better solution. Add display: flex to the .centered class.
.centered { display: flex; align-items: center}

CSS style heading - background must cover only text with a bottom border

I am trying to style a heading just like this:
But I need some help as I cannot get it correct.
I was planning on using gradient, but I must have only the text of the heading (with some padding) with a background color and gradient changes colour at a specific point in the table cell. The heading can be different words - some long & some short - so the background color cannot be stopped at a specific point. I also need the width of the cell to be underlined (border-bottom).
I am unsure if my HTML needs changing or my CSS needs changing or both or if this can be done.
My HTML code:
<div class="wrapper">
<div class="row">
<div class="heading">Heading</div>
</div>
<div class="row">
<div class="stuff">Just some stuff.</div>
</div>
</div>
My CSS code:
.wrapper {
border-spacing: 0px 0px;
display: table;
width: 100%;
}
.row {
display: table-row;
}
.heading {
border-bottom: 2px solid red;
background-color: lime;
color: blue;
direction: ltr;
display: table-cell;
font-weight: bold;
min-height: 25px;
overflow: hidden;
padding: 2px;
padding-left: 30px;
padding-right: 30px;
text-align: left;
text-transform: uppercase;
vertical-align: top;
}
.stuff {
width: 100%;
display: table-cell;
}
You should adjust the width of your heading to occupy that of only its contents. A common hack is to simply use display: inline-block. I changed a few of your styles and markup to create the lower border effect. Your wrapper and stuff classes were redundant so I removed them.
JSFiddle: http://jsfiddle.net/mkmeLzjL/11/
HTML
<div class="row">
<div class="heading">Profile</div>
</div>
<br>
<div>
<div>Just some stuff.</div>
</div>
CSS
#import url(http://fonts.googleapis.com/css?family=Open+Sans);
* {
font-family: Open Sans;
}
.row {
border-bottom: 2px solid black;
}
.heading {
background-color: black;
color: white;
display: inline-block;
font-weight: bold;
padding: 7px 30px 7px 15px;
font-size: 20px;
text-transform: uppercase;
}
Here's a solution using a pseudo-element: http://jsfiddle.net/npeqzm32/.
HTML:
<div class="wrapper">
<div class="row">
<h1>Heading</h1>
</div>
<div class="row">
<div class="stuff">Just some stuff.</div>
</div>
</div>
CSS:
* {
margin: 0;
padding: 0;
border: 0;
}
body {
padding: 10px;
}
.row {
position: relative;
}
.row h1 {
font: bold 20px/2 Sans-Serif;
background-color: #222;
color: white;
display: inline-block;
padding: 0 10px;
text-transform: uppercase;
letter-spacing: 1px;
}
.row h1:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 3px;
background-color: #222;
}
I have made some changes to output somewhat similar what you want.
DEMO HERE
HTML
<div class="wrapper">
<div class="row">
<div class="heading">Heading</div>
</div>
</div>
CSS
.row {
border-bottom:4px solid black;
}
.row .heading
{
display:inline-block;
background-color:#111;
color:#fff;
font-size:24px;
font-family:calibri;
font-weight:bold;
padding:10px 20px;
}

Horizontally center text in <p> display: table-cell?

I'm trying to center the text horizontally, but it doesn't work. It seems to be because of the display: table-cell
Would you know a work around? (note that I'm using bootstrap)
Thanks! > Codepen: http://codepen.io/goodux/pen/wgBCf
html:
<div class="feature">
<span class="glyphicon glyphicon-star feature-icon"></span>
<p class="feature-text text-center">
Gather user's feedback and engineer's requirements.
</p>
</div>
css:
.feature {
margin-bottom: 3.5em;
background-color: #f3f3f3;
border-radius: 5px;
}
span.feature-icon {
background-color: #FA6900;
border-radius: 3px;
color: #FFF;
font-size: 3em;
padding: .5em;
position: absolute;
top: 0;
}
p.feature-text {
overflow: hidden;
padding: 0 .5em 0 6.5em;
vertical-align: middle;
height: 6em;
display: table-cell;
}
.text-center {
text-align: center;
}
For display:table-cell to work correctly it needs to be inside a display:table element.
So, if you change the .feature rule to
.feature {
margin-bottom: 3.5em;
background-color: #f3f3f3;
border-radius: 5px;
display:table;
width:100%;
}
it will work as expected: http://codepen.io/gpetrioli/pen/EDtCq
of course you could avoid using display:table-cell if it is not really needed. (and in your example it looks like it is not..)
Try p {text-align: center;margin: auto }and why are you using display:table-cell ?

CSS reveal on hover HTML content

I'm wanting to create some boxed content that reveals alternate content when hovered. I've found a few examples from others questions, and tried to utilise them to what I want, but not having much luck.
The perfect example of what I'm trying to achieve is the 3 hover buttons under the "Build a Smarter WordPress Site" (just below the fold) on http://www.copyblogger.com/.
I'm assuming the static state includes an icon/image & text below, and the hover state includes an icon/image, descriptive text, and a hyperlinked button.
This is exactly what I'm wanting to reproduce. Could anyone please provide an example of this so I can understand what I need to do?
Thanks.
Edit: I understand the code Copyblogger have used from what little I can retrieve through "Inspect Element". I'm not looking to use their code - as I cannot find all the connecting commands, but something that acts the same way.
for code sample that showed in your sent link
<li class="design">
<div class="icon">Design</div>
<p>The Genesis design framework, support and dozens of stunning themes.</p><div class="btn-primary-small">Find Out More</div>
</li>
the css will be
li.design a{
display:none;
}
li.design:hover a{
display:block;
}
Here is a fiddle. There are 3 or 4 ways to do this, but you just want someone to do it for you, so I wont go into those specifics. I wrote it mobile first and assuming you can use box-sizing: border-box; - so if you can't do that - then you just add the proper widths and you'll be good to go.
HTML
<a href="#" class="block-icon">
<div class="block top-stuff">
<div class="text-w">
Top stuff
</div>
</div>
<div class="block under-stuff">
<div class="text-w">
<h4>Under stuff</h4>
<p>Some paragraph</p>
<div class="button">Call to action</div>
</div>
</div>
</a>
CSS
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
a {
text-decoration: none;
color: inherit;
}
.block-icon {
position: relative;
display: block;
width: 100%;
float: left;
border: 1px solid red;
text-align: center;
height: 10em;
margin-bottom: 1em;
}
.block-icon .block {
height: 100%;
padding: .5em;
}
.block-icon .text-w {
width: 100%;
height: 100%;
display: inline-block;
vertical-align: middle;
border: 1px solid blue;
}
.block-icon .text-w:after {
content: "\0020";
height: 100%;
display: inline-block;
vertical-align: middle;
/* this creates a second element so that they can align vertical middle to one another */
}
.top-stuff {
position: absolute;
top: 0;
left: 0;
width: 100%;
background-color: white;
opacity: 1;
transition: opacity .5s linear;
}
.under-stuff {
background-color: #eee;
}
a:hover .top-stuff {
opacity: 0;
transition: opacity .1s linear;
}
.button {
width: auto;
border: 1px solid black;
}
#media (min-width: 500px) {
.block-icon {
width: 32%;
margin-right: 2%;
}
.block-icon:nth-of-type(3) {
margin-right: 0;
}
} /* end break-point */