I have an HTML and CSS code below
.hero{
background: linear-gradient(0deg, #e8922d .11%, #eca757 127.33%);
overflow: auto;
position: fixed;
top: 0;
width: 100%;
height: 50px;
box-shadow: 3px 2px 3px #f1bd81;
}
.my-auto{
color: #FFFFFF80;
font-size: 14px;
font-weight: 600;
letter-spacing: .4px;
mix-blend-mode: normal;
font-family: 'Roboto', sans-serif;
display: flex;
justify-content: center;
align-items: center;
line-height: 50px;
}
.price_chart{
color: #FFFFFF80;
position: fixed;
right: 0;
margin-top: -38px;
margin-right: 10px;
}
<div id="header" class="hero">
<div class="dogeNav">
<span class="my-auto">
YOUR WALLET</span>
</div>
<div class="price_chart">
<p>current price - $0.05</p>
</div>
</div>
This is div header. "my-auto" class is in the center of div. "price-chart" is on the right side of div. Problem is when I resize my window two of the texts overlap each other, how could I fix that.
I didn't understood your question completely but I've made some changes on your code.
I hope this what you want.
.hero{
background: linear-gradient(0deg, #e8922d .11%, #eca757 127.33%);
overflow: hidden;
position: fixed;
top: 0;
width: 100%;
height: auto;
box-shadow: 3px 2px 3px #f1bd81;
}
.my-auto{
color: #FFFFFF80;
font-size: 14px;
font-weight: 600;
letter-spacing: .4px;
mix-blend-mode: normal;
font-family: 'Roboto', sans-serif;
display: flex;
justify-content: center;
align-items: center;
line-height: 50px;
padding-bottom: 10px;
}
.price_chart{
color: #FFFFFF;
position: fixed;
right: 0;
margin-top: -38px;
margin-right: 10px;
}
<div id="header" class="hero">
<div class="dogeNav">
<span class="my-auto">
YOUR WALLET</span>
<div class="price_chart">
<p>current price - $0.05</p>
</div>
</div>
</div>
Codepen.io
Related
I have a popup window (within the same page) which I'm attempting to put a container which scrolls horizontally into, yet it distorts the popup window and does not display anything other than the scrollbar. I'm honestly at a loss, can anyone help me here? I've looked around for solutions but I can't find anything that I can see applies to my problem.
If anyone can help, or point me in the right direction, I'd be really grateful. The scrollbar works perfectly fine when isolated, but inside the window shows like this:
Standalone:
My HTML (popup window with scrollbar inside)
<div id="formula-popup" class="popup-window">
<div>
<a onclick="closeFormulaWindow()" title="Close" class="close">X</a>
<span id="ftitle" class="title1"></span>
<form method="post" id="formulaform" name="edit">
<span>Current Formula</span>
<p id="current-formula" class="formula">Existing formula</p>
<input id="id-passer" type="hidden" name="formula-id" value="">
<!--sort out horizontal scrollbar from bookmarks here later-->
<input onclick="refreshWindow()" name="edit-formula" type="submit" value="Confirm">
</form>
<div class="h-scrollbar">
<section class="h-scrollbar-container">
<div class="outer-wrapper">
<div class="inner-wrapper">
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
</div>
</div>
<div class="pseudo-track"></div>
</section>
</div>
</div>
My CSS:
.scrollbar-container {
display: flex;
flex-direction: row;
}
.h-scrollbar {
display: flex;
max-width: 30vw;
padding: 0px 10px;
height: 20vh;
align-items: center;
justify-content: center;
overflow: hidden;
flex-shrink: 0;
}
.h-scrollbar-container {
width: 100%;
}
.outer-wrapper {
max-width: 100vw;
overflow-x: scroll;
position: relative;
scrollbar-color: #d5ac68 #f1db9d;
scrollbar-width: thin;
-ms-overflow-style: none;
}
.pseudo-track {
background-color: #f1db9d;
height: 2px;
width: 100%;
position: relative;
top: -3px;
z-index: -10;
}
.outer-wrapper::-webkit-scrollbar {
height: 5px;
}
.outer-wrapper::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 0px rgba(0, 0, 0, 0);
}
.outer-wrapper::-webkit-scrollbar-thumb {
height: 5px;
background-color: #d5ac68;
}
.outer-wrapper::-webkit-scrollbar-thumb:hover {
background-color: #f1db9d;
}
.outer-wrapper::-webkit-scrollbar:vertical {
display: none;
}
.inner-wrapper {
display: flex;
padding-bottom: 10px;
}
.pseudo-item {
height: 30px;
width: 80px;
margin-right: 15px;
flex-shrink: 0;
background-color: gray;
}
.pseudo-item:nth-of-type(2n) {
background-color: lightgray;
}
.popup-window {
position: fixed;
font-family: Arial, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: none;
}
.popup-window div {
width: 40vw;
height: 30vw;
position: relative;
margin: 10% auto 30%;
border-radius: 10px;
background: #213B54;
padding-top: 2vh;
padding-left: 1vw;
padding-right: 1vw;
padding-bottom: 2vh;
display: flex;
flex-direction: column;
}
.close {
font: Arial, sans-serif;
background: #067A9F;
color: #B5E5E7;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
border-radius: 12px;
box-shadow: 1px 1px 3px #000;
cursor: pointer;
}
.popup-window div .title1 {
font-family: Arial, sans-serif;
font-weight: normal;
font-size: 36px;
color: #EE6802;
align-self: center;
}
.popup-window form input[type=submit]:hover {
opacity: 0.8;
}
.popup-window form span {
color: #EE6802;
font-size: 22px;
}
.popup-window form {
display: flex;
flex-direction: column;
font-family: Arial, sans-serif;
}
.popup-window form span, input {
width: 100%;
}
.popup-window form input[type=submit] {
width: 20%;
background-color: #067A9F;
color: #213B54;
padding: 14px 0;
cursor: pointer;
border: none;
}
I found the solution, it was that I forgot to select an element inside the window properly and instead it was selecting all divs and so overriding the CSS properties.
This question already has answers here:
Text in Border CSS HTML
(10 answers)
Closed 3 years ago.
im trying to turn a design into code with html and css, but im stumped at a part in the hero section. What's the best way to position this logo with the border that stops around it.
attached is an image of the design i am trying to re-create
you can use before and after classes as
::before and ::after then add border and position it on the top of the corner left and right.
*{
margin: 0; padding: 0; box-sizing: border-box;
}
body{
font-family: Arial , Helvetica;
}
.banner-container{
min-height: 600px; height: 100vh; background-image: linear-gradient(to bottom, rgba(60, 53, 39, 0.6), rgba(60, 53, 39, 0.7)), url("https://images.pexels.com/photos/2015972/pexels-photo-2015972.jpeg?cs=srgb&dl=affection-baby-child-2015972.jpg&fm=jpg"); background-position: center; background-size: cover; background-repeat: no-repeat;
}
.banner-wrap{
margin: 0 auto; max-width: 960px; height: 100%; display: flex; align-items: center; justify-content: center;
}
.banner-box{
border-bottom: solid #A58758 4px; border-left: solid #A58758 4px; border-right: solid #A58758 4px; width: 500px; display: flex; flex-direction: column; align-items: center; position: relative; padding: 50px; margin-top: 100px;
}
.banner-box::before{
content: "";
width: 127px;
border: solid #A58758 2px;
position: absolute;
top: -4px;
left: -4px;
}
.banner-box::after{
content: "";
width: 127px;
border: solid #A58758 2px;
position: absolute;
top: -4px;
right: -4px;
}
.banner-box img{
position: absolute; top: -135px; padding: 5px;
}
.banner-box h2{
color: #fff; font-size: 2.5rem;
}
.banner-box h1{
color: #fff; margin: 5px 0; text-transform: uppercase; font-weight: 400; font-size: 3.8rem; letter-spacing: .4rem;
}
.banner-box h3{
color: #A58758; text-transform: uppercase; font-size: 2.3rem; font-weight: 400; letter-spacing: .6rem;
}
a{
background: #A58758; color: #fff; text-decoration: none; text-transform: uppercase; padding: 15px 25px; position: absolute; bottom: -25px; letter-spacing: .1rem;
}
<div class="banner-container">
<div class="banner-wrap">
<div class="banner-box">
<img src="https://www.thorndalemanors.com/wp-content/uploads/2019/01/thorndale-footer.svg">
<h2>Refined Luxury</h2>
<h1>Singles</h1>
<h3>In Brampton</h3>
Learn More
</div>
</div>
</div>
check its working properly
This is what I would do:
Wrapper element (.box-border) with two children: .box-border__top & .box-border__img
Put a border on .box-border but no top border
For the top border, use .box-border__top consisting of three elements:
.box-border__top:before: a line
.box-border__img: the logo, aligned in the center
.box-border__top:after: a line
To add spacing around the image, use .box-border__content with padding: 5em
body {
background: url(https://www.goodfreephotos.com/albums/vector-images/farm-landscape-illustration-vector-graphics.png);
background-size: cover;
}
.box-border { /* All side borders by the top */
border: .5em solid brown;
border-top: 0;
text-align: center;
}
.box-border__top { /* Align the image & borders */
display: flex;
}
.box-border__top:before,
.box-border__top:after {
content: '';
display: block;
width: 100%;
border-top: .5em solid brown; /* Sections of the top image */
}
.box-border__img { /* Center Image */
transform: translateY(-50%);
margin: 0 0 -99%;
}
/* Add some padding on the bottom */
.box-border__content { padding: 5em; }
<div class="box-border">
<div class="box-border__top">
<img class="box-border__img" src="https://upload.wikimedia.org/wikipedia/commons/6/66/Android_robot.png" width="100" height="90" />
</div>
<div class="box-border__content">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Robogarden_img.png/800px-Robogarden_img.png" width="300" />
</div>
</div>
I have a div called title-inverse that I put a different background color behind than the container it sets in. The container is black and title-inverse has a white background color. I am wanting the white background color to stop right after the title ends.
Does anyone see what I am doing wrong?
Where the blue is in this image is where I want the black to be.
.section-wrap {
height: 80vh;
width: 100%;
position: relative;
}
.section-block {
height: 100%;
display: inline-block;
vertical-align: top;
position: relative;
overflow: hidden;
}
.sec-text {
width: 30%;
background: #000;
}
.section-content-left, .section-content-right {
width: 70%;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.title-inverse {
background: #FFF;
color: #000;
padding: 5px 10px 2px 15px;
font-family: 'Roboto', sans-serif;
font-size: .8rem;
font-weight: 500;
line-height: 1.4em;
margin-top: 15%;
display: inline-block;
}
.section-title:after {
margin-top: 3px;
height: 2px;
width: 70px;
background: #C3C3C3;
display: block;
}
.section-description, #about-list li {
color: #777;
font-family: 'Roboto', sans-serif;
font-size: .5rem;
line-height: 1.5em;
padding-top: 30px;
}
<section class="section-wrap">
<div class="section-block right sec-img">
<div id="img2" class="back" title=""></div>
</div>
<div class="section-block sec-text left">
<h2 class="title-inverse">ALUMINUM EXTRUDED PROFILE</h2>
<div class="section-content-right" id="right-sec2">
<p class="section-description">
Our team has worked with both small start-ups to established corporations with the task of enhancing their online presence by refining
their brand to reach optimum user communication. Our ultimate goal is to improve brand awareness, while making connections with the clients' user-base.
</p>
</div>
</div>
</section>
One option that might be close to what you want is box-decoration-break, but it is an experimental feature, so support is not great (especially IE and Edge): https://caniuse.com/#feat=css-boxdecorationbreak
html,
body {
height: 100%;
margin: 0;
}
.section-wrap {
width: 600px;
position: relative;
height: 100%;
}
.section-block {
height: 100%;
display: inline-block;
vertical-align: top;
position: relative;
overflow: hidden;
}
.sec-text {
width: 30%;
background: #000;
}
.section-content-left,
.section-content-right {
width: 70%;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.title-inverse {
font-family: 'Roboto', sans-serif;
font-size: .8rem;
font-weight: 500;
line-height: 1.4em;
margin-top: 15%;
}
.title-text {
background: #FFF;
color: #000;
padding: 5px 10px 2px 15px;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
.section-description {
color: #777;
font-family: 'Roboto', sans-serif;
font-size: .5rem;
line-height: 1.5em;
padding-top: 30px;
}
<section class="section-wrap">
<div class="section-block right sec-img">
<div id="img2" class="back" title=""></div>
</div>
<div class="section-block sec-text left">
<h2 class="title-inverse"><span class="title-text">ALUMINUM EXTRUDED PROFILE</span></h2>
<div class="section-content-right" id="right-sec2">
<p class="section-description">
Our team has worked with both small start-ups to established corporations with the task of enhancing their online presence by refining their brand to...
</p>
</div>
</div>
</section>
Basically, I changed the title to:
<h2 class="title-inverse"><span class="title-text">ALUMINUM EXTRUDED PROFILE</span></h2>
And its CSS rules to:
.title-inverse {
font-family: 'Roboto', sans-serif;
font-size: .8rem;
font-weight: 500;
line-height: 1.4em;
margin-top: 15%;
}
.title-text {
background: #FFF;
color: #000;
padding: 5px 10px 2px 15px;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
I'm trying to create the image in the link with only html and css. There are a number of elements that would need to "stack" on top of one another.
I am having a difficult time understanding inheritance, nesting, etc. Here's the code I've written so far:
.heart {
position: relative;
margin-top: 20px;
background-color: #000000;
opacity: .8;
width: 65px;
height: 30px;
border-radius: 15px;
display: inline;
}
.box {
margin: 75px auto;
position: relative;
height: 490px;
width: 700px;
background-color: #18a0ff;
box-shadow: 1px 15px 50px 2px;
display: flex;
}
.thumbnail_image {
position: absolute;
float: left;
display: inline-block;
top: 0px;
left: 0px;
}
.text_container {
top: 60px;
left: 200px;
right: 100px;
width: 400px;
height: 338px;
position: relative;
display: flex;
}
h1 {
font-color: #ffffff !important;
text-transform: uppercase;
font-size: 60px;
font-family: Montserrat;
font-weight: 700;
line-height: 1.1;
text-align: left;
}
<div class="box">
<div class="heart">
</div>
<div class="thumbnail_image">
<img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457298445/Sheldon_Pic_l3cprk.jpg">
</div>
<div class="text_container">
<h1>Don't You think that if I were wrong, I'd know it?</h1>
</div>
</div>
My concern is how to properly place the heart dialog, the text container, and the image overlay. I seem to be misunderstanding proper inheritance syntax or structure.
Use position:absolute; on heart dialog, text container, and image overlay elements and then position them correctly with the left and right properties.
Absolute positioning and z-index are the key words involved in stacking images with HTML and CSS.
I went ahead and mocked up your image with some html/css to give you an idea of implementation.
Z-index is not relevant in this particular example since you only require one layer above the base, which is automatically given to you with absolute positioning, however if you had multiple layers you would need to set the z-index to a number value where lower numbered z-indexes appear at the bottom and higher z-indexes appear at the top.
Here's my code, hope it helps:
body {
background-color: grey;
}
.container {
position:fixed;
height: 500px;
width: 700px;
background-image: url(http://i.stack.imgur.com/MS8X8.png);
background-position: 46% 52%;
background-size: 150%
}
.hearts {
position: absolute;
background-color: rgba(149, 165, 166,.5);
color: white;
right: 40px;
top: 15px;
padding: 15px 25px 15px 25px;
border-radius: 15px
}
.blue {
width: 550px;
height: 500px;
background-color: rgb(102,173,255);
float: right;
}
h1, h5 {
position: absolute;
font-family: sans-serif;
color: white;
text-transform: uppercase;
}
#quote {
left: 200px;
top: 30px;
font-size: 60px;
}
#attr {
left: 200px;
top: 450px;
}
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" href = "main.css">
</head>
<body>
<div class = "container">
<div class = "hearts">423</div>
<div class = "blue">
<h1 id = "quote">don't you <br> think that <br> if i were </br>wrong,<br> i'd know it?</h1>
<h5 id = "attr">-Sheldon Cooper</h5>
</div>
</div>
</body>
</html>
Understanding the stacking order
In your case, the natural stacking order will do the job; this is nicely explained over on the MDN. The main thing to understand is that elements will overlap those that come before them in the markup. This is better explained with a simple example:
div {
position: absolute;
background: red;
height: 100px;
width: 100px;
top: 0;
left: 0;
}
.two {
background: blue;
top: 10px;
left: 20px;
}
.three {
background: green;
top: 20px;
left: 40px;
}
<div class="one">1</div>
<div class="two">2</div>
<div class="three">3</div>
With that out of the way...
Let's make these!
Feel free to jump to the complete example at the end of this answer!
Want to use some pedantic semantics?
A <blockquote> element to wrap everything together in a semantic container.
A <nav> element to contain the back and forward navigation
A <cite> element that contains the name of the person quoted
Our markup now looks like this:
<blockquote>
<p>Don't You think that if I were wrong, I'd know it?</p>
<cite>Sheldon Cooper</cite>
<a href="#" class="love-counter">
<3 123
</a>
<nav>
Previous
Next
</nav>
</blockquote>
The CSS
Main background image and color
These can be placed as a background on the blockquote itself. You can use background-size to ensure that the image always has the same dimensions. (It will obviously distort images which have an incorrect size)
blockquote {
background: #18a0ff url(image-url) no-repeat;
background-size: 170px 490px;
}
Add the transparent grey background and quotation character
This can be added with a absolutely positioned before pseudo-element of blockquote. The element is stretched out with left / right / bottom along with a width that matches the image. The transparent grey overlay and transparent text is provided by rgba color.
blockquote:before {
content: '\201C';
position: absolute;
left: 0;
top: 0;
bottom: 0;
padding-top: 30px;
font-size: 2.4em;
text-align: center;
background: rgba(0,0,0,0.7);
width: 170px;
color: rgba(255,255,255,0.3);
}
Align the main quote text along with its citation
In order to incorporate smaller quotes, it could be more visually pleasing to vertically center the main text. We can use the display: flex property along with justify-content to easily achieve this; the flex-direction: column property stacks the main quote over the top of the citation. The blockquote is also given left and right padding to appropriately position it horizontally.
blockquote {
display: flex;
justify-content: center;
flex-direction: column;
padding: 0 140px 0 200px;
}
Position the back / forward navigation and love counter
These are easily located with position: absolute along with the appropriate left / right / bottom / top properties. They will look something like this:
.love-counter {
position: absolute;
right: 20px;
top: 20px;
}
nav {
position: absolute;
left: 0px;
bottom: 20px;
}
Complete example
Compatibility: IE 11+ and all modern browsers.
You might consider a javascript method to shrink the font size for larger quotes.
#import url(https://fonts.googleapis.com/css?family=Passion+One:400,700);
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
blockquote {
background: #18a0ff url(http://i.stack.imgur.com/e3nDc.jpg) no-repeat;
background-size: 170px 490px;
height: 490px;
color: #FFF;
font-family: 'Passion One', cursive;
font-size: 4.2em;
position: relative;
display: flex;
justify-content: center;
flex-direction: column;
padding: 0 140px 0 200px;
font-weight: 400;
line-height: 1;
width: 650px;
text-transform: uppercase;
}
blockquote p {
margin: 0;
margin-top: 0.75em;
}
cite {
font-size: 0.25em;
font-weight: 400;
margin-top: 2em;
}
cite:before {
content: '\2014 '
}
blockquote:before {
content: '\201C';
font-size: 2.4em;
padding-top: 30px;
text-align: center;
background: rgba(0, 0, 0, 0.7);
width: 170px;
color: rgba(255, 255, 255, 0.3);
position: absolute;
left: 0;
top: 0;
bottom: 0;
}
.love-counter {
color: #FFF;
text-decoration: none;
font-size: 0.2em;
position: absolute;
right: 20px;
top: 20px;
font-family: helvetica;
font-weight: bold;
background: rgba(0, 0, 0, 0.2);
padding: 0 10px;
border-radius: 10px;
height: 30px;
line-height: 30px;
min-width: 60px
}
nav {
position: absolute;
left: 0px;
bottom: 20px;
font-size: 0;
width: 170px;
text-align: center;
}
nav a:before,
nav a:after {
font-size: 36px;
width: 50%;
display: inline-block;
color: #FFF;
}
nav a:first-child:before {
content: '<';
}
nav a:last-child:after {
content: '>';
}
.x-large {
background-image: url(http://i.stack.imgur.com/qWm5m.jpg);
}
.x-large p {
font-size: 0.62em;
}
<blockquote>
<p>Don't You think that if I were wrong, I'd know it?</p>
<cite>Sheldon Cooper</cite>
<3 123
<nav>
Previous
Next
</nav>
</blockquote>
<h2>Larger quote</h2>
<blockquote class="x-large">
<p>Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.</p>
<cite>Albert Einstein</cite>
<3 123
<nav>
Previous
Next
</nav>
</blockquote>
html,
body,
box,
thumbnail_image,
overlay,
h1,
h3,
h6,
p,
body {
width: 100%;
padding-bottom: 25px;
}
input {
font-family: "Roboto";
position: absolute;
top;
25.5px;
font-weight: 700;
font-size: 14px;
color: #fff;
background-color: transparent;
text-align: right;
border-width: 0;
width: 100%;
margin: 0 0 .1em 0;
}
.heart_button {
position: absolute;
top: 25.5px;
right: 55px;
}
heart_button:hover,
heart_button:active,
heart_button:focus {
color: #dd0239;
}
.heart_background {
position: absolute;
top: 20px;
right: 20px;
background-color: #000000;
opacity: .1;
width: 65px;
height: 30px;
border-radius: 15px;
}
.box {
margin: 30px auto;
position: relative;
height: 490px;
width: 700px;
background-color: #18a0ff;
box-shadow: 1px 15px 50px 2px;
}
.quote_image {
position: absolute;
opacity: .1;
top: 62px;
left: 51px;
}
.image_overlay {
background-color: #282a37;
width: 170px;
height: 490px;
position: absolute;
float: left;
}
.thumbnail_image {
position: absolute;
float: left;
opacity: .12;
display: inline-block;
top: 0px;
left: 0px;
}
.text_container {
left: 200px;
width: 400px;
height: 338px;
position: absolute;
}
h1 {
color: #fff;
text-transform: uppercase;
font-size: 60px;
font-family: Montserrat;
font-weight: 700;
line-height: 1.1;
text-align: left;
}
.author_name {
position: absolute;
left: 206px;
bottom: 0px;
}
h3 {
font-family: Open Sans;
font-weight: 700;
letter-spacing: 1px;
text-transform: uppercase;
font-size: 14px;
text-align: left;
color: #fff;
}
p {
font-family: "Roboto";
font-weight: 700;
font-size: 14px;
color: #fff;
text-align: center;
}
h6 {
font-family: Open Sans;
font-weight: light;
font-size: 22px;
letter-spacing: 2px;
text-transform: uppercase;
text-align: center;
}
html {
background: linear-gradient(209deg, #E5ECEF 40%, #BBC2C5 100%) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#footer {
clear: both;
}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="box">
<div class="heart_button">
<img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457311522/little_heart_jle1j3.png">
</div>
<div class="heart_background">
</div>
<div class="image_overlay">
</div>
<div class="thumbnail_image">
<img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457298445/Sheldon_Pic_l3cprk.jpg">
</div>
<div class="text_container">
<h1>Don't You think that if I were wrong, I'd know it?</h1>
</div>
<div class="author_name">
<h3> - Sheldon Cooper </h3>
</div>
<div class="quote_image">
<img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457314397/quotations_image_wfwimc.png">
</div>
</div>
</body>
<footer>
<div>
<h6>A Project by Charles Bateman</h6>
</div>
</footer>
I'm trying to create a template for some rotating spotlights we create here at work, and what I'm trying to do should be rather simple.
Here is my fiddle: http://jsfiddle.net/aeromax/2t4k4cf9/
What I'm trying to do, is to get #spotlightCTA to float right (easily doable) and align to the bottom of the #spotlightTitle, so that the call to action moves up or down depending on how tall the title is.
Here is the styles associated with these two divs:
#spotlightTitle {
width: auto;
height: auto;
display: inline-block;
bottom: 0px;
}
#spotlightCTA {
position: relative;
display: inline-block;
width: 300px;
text-align: right;
cursor: pointer;
right: 0px;
float: right;
}
And my HTML
<div id="spotlightContent">
<div id="spotlightTitle">
<div class="title">This is a test title.<br>Let's make it longer.
</div>
</div>
<div id="spotlightCTA" class="animate">
<span>This is a call to action.</span>
<button type="">Test button</button>
</div>
</div>
If I float right, it aligns to the top. If I remove the float, it aligns to the bottom but I can't get it to align to the right.
Thanks in advance!
Flexbox can do that.
div {
background-color: rgba(10, 10, 10, .2);
}
/*Containers*/
#spotlightContainer {
position: relative;
height: 200px;
width: 646px;
padding: 10px 20px 0px 20px;
background-color: rgba(0, 0, 0, .4);
}
#spotlightContent {
width: 646px;
height: auto;
padding: 30px 0px 0px 0px;
display: flex;
justify-content: space-between;
align-items: flex-end;
}
#spotlightTitle {
width: auto;
height: auto;
display: inline-block;
bottom: 0px;
}
/*CTA*/
#spotlightCTA {
position: relative;
display: inline-block;
width: 300px;
text-align: right;
cursor: pointer;
right: 0px;
float: right;
}
#spotlightCTA span {
font-family: "Open Sans", "Helvetica Neue", helvetica, arial, sans-serif;
font-weight: 300;
color: #fff;
display: inline-block;
padding: 5px 0px 0px 0px;
}
#spotlightCTA button {
background-color: #ffd200;
border-radius: 0px;
border: none;
margin: 0px 0px 0px 15px;
padding: 5px;
vertical-align: text-bottom;
}
.title {
font-family: "Oswald", "Helvetica Neue", helvetica, arial, sans-serif;
color: #fff;
font-weight: 600;
max-width: 400px;
font-size: 32px;
line-height: 1.2;
display: inline-block;
}
<div id="spotlightContainer">
<div id="spotlightContent">
<div id="spotlightTitle">
<div class="title">This is a test title.
<br>Let's make it longer.
</div>
</div>
<div id="spotlightCTA" class="animate">
<span>This is a call to action.</span>
<button type="">Test button</button>
</div>
</div>
</div>