Position absolute bottom + scroll fix - html

I have the following element:
Where the "1 comment" button container is positioned absolute to the main container which is relative positioned.
There problem is when I resize it and scroll down, the "1 comment" button container is going up few px. I want it to keep it in the bottom.
Like a sticky footer positioned fixed to the main container.
I wouldn't want to use javascript for this.
You can see the code live, here.

Place all content in a div with:
overflow: scroll;
and put the footer outside the div with:
position: absolute; bottom: 0; width: 100%; margin: 0; padding: 0;

You should put everything in the container except the subtitle_box bottom inside a different container.
Then set the overflow-y on the different container, with a absolute position, and a bottom offset of the height of the subtitle_box bottom.
Something like this
<div id="container">
<div class="inner-container">
<div class="title_box">
<h1>Default Project</h1>
<p>September 29 2015</p>
</div>
<div class="subtitle_box high">
<h2>Incomplete work</h2>
</div>
<div class="subtitle_box dark">
<button class="btn btn_toggle"></button>
<h2>Task 1</h2>
<button class="btn btn_menu"></button>
</div>
<div class="subtitle_box">
<button class="btn btn_toggle"></button>
<h2>Goal</h2>
</div>
<div class="text_box">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="subtitle_box">
<button class="btn btn_toggle"></button>
<h2>Involved in this task</h2>
</div>
<div class="extra_box">
<div class="contact_box">
<button class="btn btn_toggle"></button>
<p class="bold">Samuel Rush</p> <span class="dot"></span>
<p>Strive Technologies</p>
<button class="btn right">Contact</button>
</div>
<div class="skills_box">
<p>PHP,CSS,Joomla,MySQL,JavaScript,HTML5</p>
</div>
</div>
</div>
<div class="subtitle_box bottom">
<button class="btn comment">1 Comment</button>
</div>
</div>
And then add the following css
.inner-container {
position:absolute;
left:0;
top:0;
right:0;
bottom:25px;
overflow-y:auto;
}
.bottom {
height:25px;
position:absolute;
bottom:0;
left:0;
right:0;
padding:0;
}
See http://jsfiddle.net/yhgsddcz/1/

You just need to put the .subtitle_box outside of your #container
You could use a wrapper to have some basic style like the madding, text-align.

remove position: relative from #container that wrap your comment box, .subtitle_box bottom will be relative to #pane instead.it work like a charm.
Congratulation !!!

Related

Rotate text 90 degrees and vertically center next to wrapped inline text

I am trying to rotate text 90 degrees and vertically center it next to inline wrapped text. I need to keep the text inline so I can left-align the text itself, then center the whole thing when the text wraps.
It seems to work fine in Chrome when the text is on one line and when wrapped. In Firefox it seems to work fine when the text is on one line, but when wrapped, it does not vertically center the rotated text.
It seems like Firefox is not recognizing the height of the wrapped text.
Here is a fiddle showing what I'm working with. https://jsfiddle.net/hemmieweizen/7t5gh91z/12/ Notice on Firefox when you decrease the width of the output and the text wraps, the vertical text does not continue to center.
.title-container {
font-size: 70px;
position: relative;
}
.title-container .title {
position: relative;
}
.title-container .pre-title {
position: absolute;
bottom: 50%;
left: -55px;
transform: rotate(-90deg);
transform-origin: center bottom;
height: 22px;
border-bottom: 1px solid #000;
font-size: 16px;
text-transform: uppercase;
}
<h2 class="title-container m-b-0">
<span class="title">
<span class="pre-title h6 m-b-0">Your Agent</span>
Charles Smith
</span>
</h2>
Try to use a layout like flex; make both <span>Charles Smith</span> and <span>Your Agent</span> direct children of <h2> rather than nested children. Remove the hard-coded position rules from these elements, and let the flexbox manage them for you. You can still refine their positions with mere margin and padding.
#import url("https://d133rs42u5tbg.cloudfront.net/hero/assets/css/kv-custom-colors.css");
.title-container {
font-size: 70px;
position: relative;
display: flex; /* ADDED THIS NEW RULE */
flex-direction: row; /* ADDED THIS NEW RULE */
}
.title-container .pre-title { /* DID NOT CHANGE ANYTHING HERE */
position: absolute;
bottom: 50%;
left: -55px;
transform: rotate(-90deg);
transform-origin: center bottom;
height: 22px;
border-bottom: 1px solid #000;
font-size: 16px;
text-transform: uppercase;
}
.title-container .title {
/* REMOVED OLD POSITION RULE */
}
<section id="custom-about" class="position-relative p-y-3">
<div class="container p-y-3">
<div class="row">
<div class="col-xs-12 col-md-6">
<h2 class="title-container m-b-0">
<!-- CHANGED HIERARCHICAL STRUCTURE HERE -->
<span class="pre-title h6 font-sans m-b-0">Your Agent</span>
<span class="title">Charles Smith</span>
</h2>
</div>
<div class="col-xs-12 col-md-6 m-t-2">
<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. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
<div class="col-xs-12 col-md-6 col-md-offset-6">
<div class="text-center">
<a class="btn btn-white" href="contact">Contact</a>
</div>
</div>
</div>
</div>
</section>

How to place background image and text inline in Bulma CSS?

I am creating a portfolio page. I am using Bulma. The thing I want is to place the background image and text inline.
Here's the code:
<section class="hero is-halfheight upload-descr" style = "height: 37em">
<div class="hero-body">
<div class="container">
<div class="clearfix"></div>
<hr class = "rm-descr-bar" style = "float: left;"></hr>
<div class="clearfix"></div>
<h1 class = "title">
Loren Ipsum
</h1>
<div class="content rm-has-medium-size">
<p class = "upload-descr-exp" aria-live = "polite" aria-atomic = "true">Lorem ipsum dolor sit amet, consectetur adipiscing<br />elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />Ut enim ad minim veniam, quis nostrud exercitation<br />ullamco laboris nisi ut aliquip ex ea<br />ea commodo consequat. Duis aute irure dolor.</p>
</div>
</div>
</div>
</section>
The thing I want is background image shifted at right in <div class = "container">. However it gets cropped. I messed up with height and width of the container. This affected the text inside the container i.e. it was not vertically centered anymore. Please help.
I want to achieve this:
I tried:
<section class="hero is-halfheight upload-descr section" style = "height: 37em">
<div class="hero-body container" style = "background: url('/img/pic.png') no-repeat right; background-size: contain;">
<div class="container">
<div class="clearfix"></div>
<hr class = "rm-descr-bar" style = "float: left;"></hr>
<div class="clearfix"></div>
<h1 class = "title">
Loren Ipsum
</h1>
<div class="content rm-has-medium-size">
<p class = "upload-descr-exp" aria-live = "polite" aria-atomic = "true">Lorem ipsum dolor sit amet, consectetur adipiscing<br />elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />Ut enim ad minim veniam, quis nostrud exercitation<br />ullamco laboris nisi ut aliquip ex ea<br />ea commodo consequat. Duis aute irure dolor.</p>
</div>
</div>
</div>
</section>
I achieved the thing I wanted after trying above code. However, on decreasing viewport size, background image and text appears on above other maybe they got vertical and horizontal centered. Please help me. How can I place background image and text next to each other without any bugs?
Here's the bug:
Idea
Left side text and right side the image
Give all the same background color
Example
(The image ratio is about 4:3. Change CSS according to your needs.)
.mySection {
background-color: #F93122;
color: white;
border: 1px solid white;
}
.myHero {
padding: 50px 0 50px 75px;
}
.myHero .hr {
display: inline-block;
width: 100px;
height: 15px;
background: white;
border-radius: 20px;
margin-bottom: 15px;
}
.myHero h1 {
font-size: 50px
}
#media(max-width: 768px) {
.myHero {
padding: 50px !important;
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css">
<section class="mySection">
<div class="columns is-vcentered">
<div class="column is-5-tablet is-5-desktop">
<div class="myHero">
<div class="hr"></div>
<h1>Loren Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dicta a et ipsa voluptates in velit rem minus nihil, blanditiis nisi, quidem tempore quos qui quas. Blanditiis hic dolorem fugiat? Blanditiis!</p>
</div>
</div>
<div class="column is-7-tablet is-7-desktop">
<figure class="image is4by3">
<img src="http://i64.tinypic.com/29gedzq.png">
</figure>
</div>
</div>
</section>
Hint
Bulma#image
You used two times container class as per my thought that is why you getting this bug. Are you want change background color red to and img ?

How do I put space between my Bootstrap columns? [duplicate]

This question already has answers here:
Borders between columns of Bootstrap Grid not working
(3 answers)
Closed 5 years ago.
I am trying to make a website using Bootstrap, and when I tried putting two columns beside each other (they together come out to the 12 allowed columns in bootstrap) they just get squished together. I tried adding a margin to one of the columns, but that just caused the smaller column to wrap and end up under the larger one.
<div class="container">
<div class="row">
<div class="col-sm-8s">
<div class="featuredPost">
<h2>Featured Post <hr></h2>
<img src="Images/placeholderImg.jpg" alt="Featured Image">
<p>
Portland aesthetic cardigan cloud bread brooklyn food truck blog leggings quinoa street art franzen. Fixie swag artisan ennui vaporware cred. Church-key direct trade neutra try-hard tilde typewriter selfies butcher trust fund. Aesthetic iceland small batch ugh health goth you probably haven't heard of them glossier fixie before they sold out fingerstache knausgaard cloud bread slow-carb. Man bun gluten-free sartorial, thundercats blog man braid banjo. Skateboard poke hot chicken pickled, tote bag tacos 90's..Read More »
</p>
</div>
</div>
<aside class="authorBio col-sm-4">
<div class="widget">
<div class="row">
<img class="col-sm-6" src="Images/AimeeAvatar.jpg" alt="Avatar">
<h1 class="col-sm-6">Aimée LeVally</h1>
</div>
<hr>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing 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.
Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur.
</p>
</div><!-- widget -->
</aside>
</div><!-- row -->
</div>
.authorBio {
background-color: #fff4e8;
padding: 15px 50px 30px 50px;
text-align: justify;
border: 5px solid #f7ddc0;
}
.authorBio h1 {
text-align: justify;
color: #ad4b34;
}
.authorBio img {
width: 50%;
-webkit-border-radius: 100%;
-moz-border-radius: 100%;
border-radius: 100%;
}
.featuredPost {
background-color: #fff4e8;
padding: 15px 50px 30px 50px;
text-align: justify;
border: 5px solid #f7ddc0;
}
.featuredPost img {
width: 100%;
padding: 0 0 0 0;
margin: 0;
}
.featuredPost p {
padding-top: 25px;
}
I advise you to only use the column classes inside of <div> tags.
<div class="widget">
<div class="row">
<div class="col-sm-6">
<img src="Images/AimeeAvatar.jpg" alt="Avatar">
</div>
<div class="col-sm-6">
<h1 class="col-sm-6">Aimée LeVally</h1>
</div>
</div>
<hr>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing 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.
Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur.
</p>
</div><!-- widget -->
You need to create div in columns, like:
<div class="col-sm-8">
<div class='extra_div_1'>
<div class="featuredPost">
<h2>Featured Post <hr></h2>
<img src="Images/placeholderImg.jpg" alt="Featured Image">
<p>
<a>Portland</a>
</p>
</div>
</div>
</div>
<aside class="authorBio col-sm-4">
<div class='extra_div_2'>
<div class="widget">
<div class="row">
<img class="col-sm-6" src="Images/AimeeAvatar.jpg" alt="Avatar">
<h1 class="col-sm-6">Aimée LeVally</h1>
</div>
<hr>
<p>
Lorem
</p>
</div>
</div>
</aside>
CSS:
.extra_div_1{
padding:0px 15px 0px 15px; // or margin
}
.extra_div_2{
padding:0px 15px 0px 15px; // or margin
}
Why ... because when You use margins for column - width became bigger then col-md-12 and Your column jump on bottom. So You need to create extra div in column and use padding/margin to make blank space between columns.
The problem is due to your applying a background-color directly to the Bootstrap Grid .col-*-* class. These classes use padding to create the spacing between each element, but a background would make it appear as though each grid element was immediately brushing up against the other.
Instead, place your background as a wrapper class - for example:
<div class="col-sm-8">
<div class="my-well">
<p>Hi I am some text</p>
</div>
</div>
With CSS along the lines of:
.my-well {
padding: 15px;
background: #999;
}
Always follow this rule with the Bootstrap grid:...
.col-* must be wrapped in .row, and only .col-* should be the
immediate child of row
https://www.codeply.com/go/uH5cQ5HB8X
Also, cols should be div, not other inline elements like img and h1. Since padding is used to create the "gutter" or spacing between columns, use a margin around the inner content of the column(s) to increase spacing. Therefore, your authorBio and featuredPost should be contained within the Bootstrap columns.
<div class="container">
<div class="row">
<div class="col-sm-8">
<div class="featuredPost">
..
</div>
</div>
<aside class="col-sm-4">
<div class="row">
<div class="col-sm-12">
<div class="authorBio">
<div class="row">
<div class="col-lg-6">
<img>
</div>
<div class="col-lg-6">
...
</div>
</div>
</div>
</div>
</div>
</aside>
</div>
<!-- row -->
</div>
https://www.codeply.com/go/uH5cQ5HB8X

Can I use one Bootstrap column width (not equaling 12) in separate rows?

I have been trying to create two separate Bootstrap rows, each with a width of 8.
Unfortunately, both rows overlap each other. I've tried various approaches to solving the problem but nothing is working.
I'm curious if this is a problem with the way I'm using column widths.
Sorry for such a simple question - I'm fairly new to all of this.
HTML
<div class="container">
<!-- HEADLINE -->
<div class="row">
<div class="short-description col-xs-8">
<div class="listing-headline">
{{ adContent?.headline }}
</div>
<div class="location-info">
{{ location?.city }}, {{ location?.state }}, {{ location?.country }}
</div>
<hr>
</div>
</div>
<!-- DETAILS OVERVIEW -->
<div class="row">
<div class="details-overview col-xs-8" *ngFor="let info of unitContent">
<div class="rental-type">
{{ info?.unitContent.propertyType }}
</div>
<div class="guest-allowance">
</div>
<div class="space-type">
</div>
<div class="bed-number">
</div>
<hr>
</div>
</div>
</div>
CSS
.short-description {
height: 80px;
padding: auto;
margin-top: 20px;
}
.listing-headline {
font-style: bold;
font-size: 3em;
line-height: 120%;
}
.location-info {
margin-top: 15px;
font-weight: 300;
font-size: 1.4em;
}
.details-overview {
}
Your Bootstrap looks fine to me. I think it might be a CSS issue because if you remove the CSS there's no overlap.
Adding a margin-top in .details-overview may help.
Your class .listing-headline has a to big font size / line height for your .short-description class with height of 80px;
You have to decrease the font size or increase the height of .short-description for avoiding overlapping in your case.
When you delete the height of .short-description it looks nice:
.short-description {
margin-top: 20px;
}
Nothings wrong with your code. I think overlapping of both rows with each other is because of some codes missing with bootstrap stylesheets (either of bootstrap.css or bootstrap.min.css) you are using. It's better to get a new copy of it.
<div class="container">
<div class="row">
<div class="col-xs-8">
<div class="listing-headline">
HEADLINE 1
</div>
<!--/col-xs-8-->
<div class="location-info">
CITY, STATE, COUNTRY
</div>
<!--/col-xs-8-->
<hr>
</div>
<!--/col-xs-8-->
</div>
<!--/row-->
<div class="row">
<div class="col-xs-8">
<div class="rental-type">
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<!--/rental-type-->
<div class="guest-allowance">
</div>
<!--/guest-allowance-->
<div class="space-type">
</div>
<!--/space-type-->
<div class="bed-number">
</div>
<!--/bed-number-->
<hr>
</div>
<!--/col-xs-8-->
</div>
<!--/row-->
</div>
<!--/container-->
<style type="text/css">
.short-description {
height: 80px;
padding: auto;
margin-top: 20px;
}
.listing-headline {
font-style: bold;
font-size: 3em;
line-height: 120%;
}
.location-info {
margin-top: 5px;
font-weight: 300;
font-size: 1.4em;
}
</style>

Place footer below taller of two overlapping elements in CSS

I have a block of text that goes on top of a picture. Then below this there is a footer. But the text comes from a database, so sometimes the text is taller than the picture and sometimes shorter. I want the footer to come below the "whole thing" in either case.
Like this -- imagine the XXX's are the picture
Scenario 1:
XXXXXXXXXXXXXXXX
XXXX Short XXXX
XXXX text XXXX
XXXXXXXXXXXXXXXX
-- Footer --
Scenario 2:
XXXXXXXXXXXXXXXX
XXXX Long XXXX
XXXX text XXXX
XXXX runs XXXX
past
the
picture.
-- Footer --
It's easy enough to put the text on top of the picture with position: absolute for one or the other. But then the footer gets positioned without regard to the absolute element.
At the moment I've got two different versions of the screen, one where the picture is static and the text is absolute, for cases where I expect the text to be longer; and one where the text is static and the picture is absolute, for cases where the text is longer. This works, but only because I know what data is in the database today. I could have the program examine the text, but I have no way to know how tall it will lay out without knowing the size of the window the user sets for his browser, not to mention font sizes, etc.
Maybe position: absolute isn't the right way to do this?
Update *
Someone suggested I make a fiddle. I was about to, but I see Adam B Smith made one that illustrates my problem very well: http://jsfiddle.net/DIRTY_SMITH/EgLKV/6183/
That fiddle looks great if the text is taller than the image. Now delete a bunch of text so that the text is shorter than the image, and you see the footer overlaps the image.
OK this one will do it for you http://jsfiddle.net/DIRTY_SMITH/EgLKV/6185/
lol
#container{min-height: 400px;}
#image
{
position:absolute;
z-index:-9999;
left:0;
top:0;
}
#text
{
z-index:9999;
width: 200px;
color:red;
font-size:24px;
font-weight:bold;
}
.footer {
background:#ffab62;
width:100%;
height:100px;
z-index:9999;
bottom:0;
left:0;
}
If you know the size of the image, and set the container's size same as the image, it does work.
.container {
border: 1px solid red;
position: relative;
display: table;
width: 250px;
height: 193px;
}
.container img {
position: absolute;
z-index: -1;
}
.container span {
background: rgba(255,255,255,.7);
display: table;
width: 80%;
margin: auto;
margin-top: 25%;
margin-bottom: 5%;
}
.footer {
background: pink;
}
<div class="container">
<img src="http://albanyvisitors.com/WpContents/wp-content/uploads/2015/06/200px-Big-Lake-Big-Sky-Mt-Washington-by-Bill-Origer-2015-photo-contest.jpg" />
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit</span>
</div>
<div class="footer">foooooooter</div>
<br>
<div class="container">
<img src="http://albanyvisitors.com/WpContents/wp-content/uploads/2015/06/200px-Big-Lake-Big-Sky-Mt-Washington-by-Bill-Origer-2015-photo-contest.jpg" />
<span>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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
<div class="footer">foooooooter</div>