getting div to float right and align bottom of variable div - html

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>

Related

Why won't the scrolling container display in my popup window, but works outside of it?

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.

two texts overlapping each other when resizing window

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

How to align my div to the right side of container per element?

Hope your all well.
Is it possible to align my div to the right side within my container? I try using align functions but does not seem to work. is it possible?
Note, the alignment solution should be for div (chatline) and HTML code only, as i need another div to align (chatline) on the right or left etc. so please don't use CSS alignment on the hold container.
Any help would be grateful here. thanks Yummi
body {
background-color: #6B6B6B;
margin: 50px;
font-family: Arial;
color: darkgrey;
font-size: 14px;
line-height: .3;
letter-spacing: .5px;
}
#chattext {
font-family: Arial;
color: grey;
font-size: 12px;
line-height: 1.1;
letter-spacing: .5px;
}
.chatbox {
position: absolute;
width: 400px;
padding: 15px;
padding-top: 5px;
border-radius: 0px 0px 30px 30px;
background-color: rgba(0, 0, 0, .4);
grid-template-columns: 500px;
display: grid;
}
.bubble {
position: absolute;
max-width: 200px;
padding: 15px;
padding-top: 10px;
border-radius: 0px 30px 30px 30px;
background-color: rgba(0, 0, 0, .3);
}
<div class="chatbox">
<div style="height:200px">
<p class="bubble" id="chattext">This should be right > please use htnl code on this div to align</p>
<p style="margin-top:70px;" class="bubble" id="chattext">stay left</p>
</div>
</div>
You can define new class and use it in every bubble you want it in right
.right_chat {
right:0;
}
another advice id prefer to use just for one element so in my code i change it to class and use it in html code
body {
background-color: #6B6B6B;
margin: 50px;
font-family: Arial;
color: darkgrey;
font-size: 14px;
line-height: .3;
letter-spacing: .5px;
}
.chattext {
font-family: Arial;
color: grey;
font-size: 12px;
line-height: 1.1;
letter-spacing: .5px;
}
.right_chat {
right:0;
}
.chatbox {
position: absolute;
width: 400px;
padding: 15px;
padding-top: 5px;
border-radius: 0px 0px 30px 30px;
background-color:rgba(0, 0, 0, .4);
grid-template-columns: 500px;
display: grid;
}
.bubble {
position: absolute;
max-width:200px;
padding: 15px;
padding-top: 10px;
border-radius: 0px 30px 30px 30px;
background-color:rgba(0, 0, 0, .3);
}
<div class="chatbox">
<div style="height:200px"><p class="bubble chattext right_chat" id="">This should be right > please use htnl code on this div to align</p><p style="margin-top:70px;" class="bubble chattext">stay left</p></div>
</div>
Is this what you want?
I didn't change the default behavior of the bubble class. Since the bubble is position: absolute I created one extra class named right that you can add on each bubble you want to be aligned on the right.
body {
background-color: #6B6B6B;
margin: 50px;
font-family: Arial;
color: darkgrey;
font-size: 14px;
line-height: .3;
letter-spacing: .5px;
}
#chattext {
font-family: Arial;
color: grey;
font-size: 12px;
line-height: 1.1;
letter-spacing: .5px;
}
.chatbox {
position: absolute;
width: 400px;
padding: 15px;
padding-top: 5px;
border-radius: 0px 0px 30px 30px;
background-color:rgba(0, 0, 0, .4);
grid-template-columns: 500px;
display: grid;
}
.bubble {
position: absolute;
max-width:200px;
padding: 15px;
padding-top: 10px;
border-radius: 0px 30px 30px 30px;
background-color:rgba(0, 0, 0, .3);
}
.message-wrapper .bubble.right {
right: 0;
}
<div class="chatbox">
<div class="message-wrapper" style="height:200px">
<p class="bubble right" id="chattext">This should be right > please use htnl code on this div to align</p>
<p style="margin-top:70px;" class="bubble" id="chattext">stay left</p>
</div>
</div>

Issue in fixing Name tag near image

<ul class="child ">
<div style="text-align:right;"> <li class="nameBar">{{patientInfo.data.fname}} {{patientInfo.data.lname}}</li></div>
<li class="age">{{patientInfo.data.age}}|{{ patientInfo.data.gender}}</li>
<img class="breadcrumb-image" src="assets/images/user/user6.jpg" alt="...">
<li class='uhid'>UHID: {{patientInfo.data.uhid}}</li>
<li class="address">{{patientInfo.data.city}}</li>
</ul>
CSS:
.nameBar{
color:#00bcd4;
font-weight:bold;
margin: -7px 0px 0px -100px;
position: absolute;
font-size: 12px;
text-transform: capitalize;
}
.uhid{
margin:-39px 0px 0px 58px;
color:#00bcd4;
font-weight:bold;
font-size: 12px;
}
.age{
margin: 15px 0px 0px -35px;
font-size: 10px;
position: absolute;
}
.address{
margin: 4px 0px 0px 59px;
font-size: 10px;
}
.child {
position: fixed;
top: 72px;
left: 50px;
padding: 1em;
margin: 0px 0px 0px 571px;
}
.li{
border-width: 1px;
text-align:center;
float:left;
}
Always I need to start the name from right side of the image I tried with margin-right:calc(50% -(somePx)) not able to fix that name lable near the image as right side Uhid and place can any help me out in this thanks
it's not a good idea to use too much margins and absolute positioning.
take a look at this and change it to your needs.
.child {
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 1em;
display: flex;
justify-content: center;
}
.child>img {
width: 40px;
height: 40px;
margin: 0 5px;
}
.nameBar {
text-transform: capitalize;
}
.bold {
color: #00bcd4;
font-weight: bold;
font-size: 12px;
}
.small {
font-size: 10px;
}
.left,
.right {
line-height: 20px;
padding-top: 5px;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
<div class="child">
<div class="right">
<div class="nameBar bold">John Doe</div>
<div class="age small">26 Male</div>
</div>
<img src="https://picsum.photos/40" alt="...">
<div class="left">
<div class='uhid bold'>UHID: 1234</div>
<div class="address small">Paris</div>
</div>
</div>

How to vertically center div in fluid container?

I would like to be able to vertically center a div containing meta data such as Title and Author within a container that has a fluid width. In the example below, I would like the .meta div to be vertically centered within the article which is fluid width.
I tried following this article (http://css-tricks.com/centering-in-the-unknown/) but it doesn't work.
HTML
<div class="container">
<h3>Test</h3>
<article>
<div class="meta">
<div class="title"></div>
<div class="author"></div>
<img src="" />
</div>
</article>
</div>
CSS (using LESS)
.container {
h3 {
margin: -5px 0 0 0;
padding: 32px 0px 16px 0;
.freight-sans-pro;
font-size: 1.375em;
line-height: 1em;
font-weight: 200;
}
article {
max-height: 375px;
overflow: hidden;
position: relative;
z-index: 900;
margin-bottom: 2px;
background-color: #color-black;
line-height: 0em;
a {
max-height: 375px;
display: block;
img { opacity: .5; .opacity-transition; }
}
.meta {
width: 100%;
position: absolute;
bottom: 40%;
z-index: 500;
padding: 0px 10%;
color: #color-white;
font-size: 20px;
text-align: center;
.title {
margin: 0;
font-size: 2em;
line-height: 1em;
font-weight: 700;
text-shadow: 0px 2px 20px rgba(0, 0, 0, 0.7);
padding-bottom: 8px;
text-decoration: none;
display: block;
}
.author {
margin: 0;
font-size: .8em;
line-height: .75em;
font-style: italic;
text-transform: uppercase;
text-shadow: 0px 2px 20px rgba(0, 0, 0, 0.7);
text-decoration: none;
display: block;
}
}
}
}
Tried your Less but got an error in codepen.io so could not debug.
You could try something simple like this:
.container {
border: 2px solid blue;
width: 180px;
height: 120px;
overflow: hidden;
display: table-cell;
vertical-align: middle;
}
Check it working here
You might find this article useful as well: http://logconsole.com/vertical-align-center-image/
It's about vertically centring image, but in most cases you could just change image with a div.
Try this on what you want to be centered. I altered #domkoscielak's code so that it work.
.meta {
width: 180px;
height: 120px;
top: 50%;
margin-top: -60px; /*half of height*/
position: absolute;
}