Align a button at the bottom of a grid - html

I am trying to assign the button : called 'go to form' right at the bottom of the grid i have done in CSS.
I have messed around with the relative position but this seems not to want to work. Any ideas guys ?
.item {
border: 1px rgb(160,160,255) solid;
}
img {
border-radius: 2px;
border: 1px solid #ddd;
height : 100px;
width : 80%;
}
p {
font-size: 18px;
}
h1 {
font-size: 14px;
}
</style>
<div class="grid-container">
<div class="item">
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>​
<p> Sheep Dipper </p>
</div>
<div class="item">​<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>​​
<p> Laptop Request​ </p>
<h4> Use this form to request a new laptop</h4>
<button>Go to Form</button> </div>
<div class="item">​
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>​
<p> New User Request </p>
</div>
<div class="item">
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>​ ​​
<p> Permissions Management </p>
</div>
<div class="item">​​​
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>​ ​<br/>​<br/>​<br/>​​<br/>​<br/></div>
</div>

try this one :
.grid-container{
position: relative;
}
.youBtnClass {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}

Try this. Position absolute will place the button with respect to its immediate parent, and bottom attribute makes sure it starts at the very bottom of the parent.
You may add top margin in case your button lacks a gap on top of it.
.grid-container{
position: relative;
}
.youBtnClass {
position: absolute;
bottom: 0;
margin: 0 auto;
}

Related

Don't include margin/padding in width when nesting divs

I have an overlay over a clip thumbnail, and a click event to open the iFrame. The overlay will contain the JSON response data about the clip, however, I'm having trouble styling the overlay to not include the margins in the overlay's total size. This, for obvious reasons, makes aligning text very problematic.
So how would I make it so the overlay takes that same margin, without adding the margin to the overlay effectively doubling the margin entirely?
#clips {
overflow-x: scroll;
overflow-y: hidden;
display: flex;
}
.clipImg {
flex: 1;
margin-bottom: 1em;
padding-right: 1em;
}
.clipImg-overlay {
position: absolute;
display: block;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 496;
height: 272;
opacity: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, .7);
font-family: sans-serif;
}
.clipImg-container:hover .clipImg-overlay {
opacity: 1;
}
<div class="clipImg-container" data-slug="ManlyEnjoyableSowKappaPride"><img src="https://clips-media-assets2.twitch.tv/28966899744-offset-8838-preview-480x272.jpg" class="clipImg">
<div class="clipImg-overlay"><img id="channel-logo" src="https://static-cdn.jtvnw.net/jtv_user_pictures/d7747302-0948-478a-9017-976d285a2678-profile_image-150x150.png">
<div id="info-container">
<h1 id="clip-name">CODE BLUE CODE BLUE | Tip for free !loots</h1>
<p id="clip-context">CodeSpent is playing PLAYERUNKNOWN'S BATTLEGROUNDS</p>
<p id="clip-views">4 views</p>
<p id="clip-curation">Clipped by sudocodesh</p>
</div>
</div>
</div>
The .clipImg-overlay is relative to the .clipImg-container, that expands with the .clipImg margin.
To resolve this you could try to use the margin in the .clipImg-container or make a div that surrounds .clipImg-overlay and .clipImg and have the margin that is actually in .clipImg.
<style>
.clipImg {
flex: 1;
}
.clipImg-container {
margin-bottom: 1em;
padding-right: 1em;
}
</style>
<div class="clipImg-container" data-slug="ManlyEnjoyableSowKappaPride">
<img src="https://clips-media-assets2.twitch.tv/28966899744-offset-8838-preview-480x272.jpg" class="clipImg">
<div class="clipImg-overlay">
<img id="channel-logo" src="https://static-cdn.jtvnw.net/jtv_user_pictures/d7747302-0948-478a-9017-976d285a2678-profile_image-150x150.png">
<div id="info-container">
<h1 id="clip-name">CODE BLUE CODE BLUE | Tip for free !loots</h1>
<p id="clip-context">CodeSpent is playing PLAYERUNKNOWN'S BATTLEGROUNDS</p>
<p id="clip-views">4 views</p>
<p id="clip-curation">Clipped by sudocodesh</p>
</div>
</div>
</div>
or
<style>
.overlay-container {
position: relative;
margin-bottom: 1em;
padding-right: 1em;
}
</style>
<div class="clipImg-container" data-slug="ManlyEnjoyableSowKappaPride">
<div class="overlay-container">
<img src="https://clips-media-assets2.twitch.tv/28966899744-offset-8838-preview-480x272.jpg" class="clipImg">
<div class="clipImg-overlay">
<img id="channel-logo" src="https://static-cdn.jtvnw.net/jtv_user_pictures/d7747302-0948-478a-9017-976d285a2678-profile_image-150x150.png">
<div id="info-container">
<h1 id="clip-name">CODE BLUE CODE BLUE | Tip for free !loots</h1>
<p id="clip-context">CodeSpent is playing PLAYERUNKNOWN'S BATTLEGROUNDS</p>
<p id="clip-views">4 views</p>
<p id="clip-curation">Clipped by sudocodesh</p>
</div>
</div>
</div>
</div>

CSS: Background color to extend to a certain element

I have the following code
<body>
<div style="height: 35%; background-color: black;"></div>
<div id="header">
<div>
<h1>Title</h1>
<h3>Subtitle</h3>
</div>
</div>
<div id="content" class="card">
<div>
<p>
One
</p>
<p>
Two
</p>
</div>
</div>
</body>
Ideally, I would like the top portion of the page to be a certain color (black in the example), and I want the header area (which contains the <h1> and <h3> elements) to be inside the black box. Then I would like the first paragraph of the content to also be included inside the black box. Very similar to this picture:
What is the best way to go about this?
The simplest way is to use an absolute positioned pseudo element on the header
Stack snippet
body {
background-color: #ddd;
margin: 0;
}
#header {
position: relative;
color: white;
background-color: black;
}
#header::before {
content: '';
position: absolute;
top: 100%;
left: 0;
height: 60px;
width: 100%;
background-color: inherit;
}
#header div {
width: 80%;
margin: 0 auto;
padding: 10px;
}
#content {
position: relative;
width: 80%;
margin: 0 auto;
background-color: white;
}
<div id="header">
<div>
<h1>Title</h1>
<h3>Subtitle</h3>
</div>
</div>
<div id="content" class="card">
<div>
<p>
One
</p>
<p>
Two
</p>
<p>
Thre
</p>
<p>
Fou
</p>
</div>
</div>
Three steps:
Apply a gradient background to the <body>.
Create two sectioning elements: <header> and <section>
Ensure all the relevant elements in <header> and at the top of <section> have an explicitly declared height in pixels which, combined, match the height of the first part of the gradient.
Make sure that the html and body have height: 100% or min-height: 100% otherwise height 35% is not going to be 35% of the viewport height.
You can make the black background with an absolute positioned element. I suggest to look into css position(relative, absolute, fixed, static).
Here's a demo and the code:
https://jsfiddle.net/n617L6rh/
<div id="bg"></div>
<div id="header">
<div>
<h1>Title</h1>
<h3>Subtitle</h3>
</div>
</div>
<div id="content" class="card">
<div>
<p>One</p>
<p>Two</p>
</div>
</div>
html,
body {
height: 100%;
}
#bg {
height: 35%;
background: black;
position: absolute;
top: 0;
left: 0;
right: 0;
}
#header {
height: 35%;
color: #fff;
position: relative;
}

Why does all of my text appear in the same place

Well im trying to achieve a basic effect of 6 images placed next to each other ( 2 rows of 3) and want to add some text over them. But the problem is (I think) in the float = left "command" in the CSS, which indeed puts my images nicely next to each other... BUT throws all of my text in the one place instead of nicely with the appropriate image. I've been sitting and thinking on this for solid few days and have no idea what to do. Hope you can help.
CSS
.text {
position: absolute;
z-index: 100;
color: black;
width: 100%;
}
.image {
float: left;
clear: both;
padding: 2px;
position: relative;
}
HTML
<body>
<div class="row" style="width:1600px">
<div class="container">
<img class="image" src="Life.jpg" alt="Life" style="width:520px;height:360px;" />
<p class="text">Life</p>
</div>
<div class="container">
<img class="image" src="Trees are Cool.jpg" alt="Trees Are Cool" style="width:520px;height:360px;" />
<p class="text">Trees are Cool</p>
</div>
<div class="container">
<img class="image" src="Radical dinosaurs.jpg" alt="Radical Dino" style="width:520px;height:360px;" />
<p class="text">Radical Dinosaurs</p>
</div>
<div class="container">
<img class="image" src="Big Round Vuttons.jpg" alt="Big Round Buttons" style="width:520px;height:360px;"/>
<p class="text">Big Round Buttons</p>
</div>
<div class="container">
<img class="image" src="Run.jpg" alt="Run" style="width:520px;height:360px;"/>
<p class="text">Run</p>
</div>
<div class="container">
<img class="image" src="Thats crazy.jpg" alt="That's Crazy" style="width:520px;height:360px;"/>
<p class="text">That's Crazy</p>
</div>
</div>
</body>
Use following css, this will solve your problem
.text {
position: absolute;
z-index: 100;
color: black;
width: 100%;
top: 0;
}
.container {
display: inline-block;
box-sizing: border-box;
padding: 2px;
position: relative;
}
the problem is that you are positioning your image to relative. but your .text is direct child of .container by default .text find it's parent to be position relative but .container has not apply css property position relative then it find .container parent to be position relative and so on, in the end html is position relative that's why all your code stack on the top of each other.
SEE DEMO
try this
.contailer{
position: relative;
}
Add position: relative to the .container class, so it will be the .text element context. The element is positioned in relation to the context.
The context is the last parent that has position: relative / absolute / fixed. Right now the context is probably some higher level container or even the body itself, so all .text items are concentrated there.
It has to do with the position of the elements like other have pointed out
.text {
position: absolute;
z-index: 100;
color: black;
width: 100%;
top: 50px;
left: 50px;
}
.image {
padding: 2px;
position: relative;
}
.container {
float:left;
}
https://jsfiddle.net/xqf8kfd1/1/
Give 'container' class style as follows:
.container {
position: relative;
}
And remove float: left; from 'image' class
try removing the position:absolute and adding float:left to the css text class
.text {
float: left;
z-index: 100;
color: black;
width: 100%;
display: inline-block;
}

HTML, CSS aligning text inside DIV with text in parallel div

I was wondering if someone could help me with some HTML/CSS. I'm trying to line up text in a sidebar div to match the content in the content div but the only way I can see possible is adding loads of <p> </p> to html. I am wondering if there is an easier way.
Fiddle
HTML:
<div class="header">
<h3><a name="comb"></a>The combined INSPECT</h3>
</div>
<div class="left">
<p>Syntax</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>To top of page
</p>
</div>
<div class="content">
<p>
<img src="CombInspect.gif" width="649" height="338" alt="combined" />
</p>
<p>This format of the INSPECT combines the syntactic elements of the previous two formats allowing both counting and replacing to be done in one statement.</p>
</div>
CSS:
div.header {
padding: 0.5em;
color: #FFFF00;
background-color: #993300;
clear: left;
line-height: 0px;
}
div.content {
margin-left: 300px;
border-left: 1px solid gray;
padding: 1em;
background-color: #FFFFFF;
}
div.left {
float: left;
width: 270px;
padding: 1em;
background-color: #FFFFCC;
color: #5F021F;
font-size: 17px;
font-weight: bold;
}
Are you totally opposed to using jQuery (and I'm not trying to be rude, just asking if you prefer not to use it)? Otherwise, I'd suggest you get the height of your content div with .height() and set the length of your sidebar that way.
var adjustedHeight = $(".content").height()
$(".left").css("height", adjustedHeight)
Check out the fiddle here
Hope that helps :)
edit: fixed the fiddle link.
If you want To top of page to appear at the bottom, you can put your divs in a container div, with this style:
div.container {
position: relative;
}
Add a bottom class to To top of page, with these styles:
.bottom {
position: absolute;
bottom: 0px;
}
Fiddle
When you float an element it is taken out of the normal document flow. In order to achieve what you are after you can make the left sidebar position:absolute with height:100% as in this fiddle:
http://jsfiddle.net/Lze4pj61/3/
CSS:
div.header
{
padding: 0.5em;
color: #FFFF00;
background-color: #993300;
clear: left;
line-height: 0px;
}
div.content
{
margin-left: 300px;
border-left: 1px solid gray;
padding: 1em;
background-color: #FFFFFF;
}
div.left
{
position: absolute;
width: 270px;
padding: 1em;
background-color: #FFFFCC;
color: #5F021F;
font-size:17px;
font-weight:bold;
height:100%;
}
div.left .to_top {
position:absolute;
bottom:10px;
text-align:center;
}
HTML:
<div class="header">
<h3 ><a name="comb"></a>The combined INSPECT</h3>
</div>
<div class="left">
<p>Syntax</p>
<div class="to_top">
To top of page
</div>
</div>
<div class="content">
<p><img src="CombInspect.gif" width="300" height="150" alt="combined" /></p>
<p>This format of the INSPECT combines the syntactic elements of the previous two formats allowing both counting and replacing to be done in one statement.</p>
</div>
If your content div has a varying dynamic height you could use jquery in a function like this
$(document).ready(function(){
var header = $(".header");
var left = $(".left");
var content = $(".content");
if(left.height() < content.height()){
left.height(content.height())
}
$( ".thisOffSet" ).offset({ top: content.height()+header.height() });
});
You can see on this JSFIDDLE how it works by changing the window size and clicking run for it to readjust.
Hope this helps

Make mulitple divs line up next to each other inside parent div

I've searched the many similar questions like this, but none of the solutions are working. It should also be noted that I am using twitter bootstrap. I want a bunch of divs to span the entire length of the parent div at the bottom of it. I have tried putting them inside a div that text-align:center and then using float-left inside the gridPics class, and using display: inline-block, text-align :left and nothing seems to do it. The two in the example below are in the exact same spot, and I want them side by side. Here is what I have:
HTML:
<div class="row-fluid">
<div class="span8 offset2 articleContent">
<!-- These are the divs to span across, when it works there would be more than two -->
<div class="gridPics"></div>
<div class="gridPics"></div>
<!-- They will also go over this image -->
<img id="sidePic" src="img/about/aboutHeader_Mid1.png" alt="about">
</div>
<div class="span2"></div>
</div>
CSS:
.gridPics{
position: absolute;
z-index: 1;
width: 10%;
height: 20%;
background: #0000b3;
bottom: 0;
float: left;
}
.articleContent{
position: relative;
box-shadow: 0 0 5px 5px #888;
}
#sidePic{
position: relative;
z-index: -1;
}
Here is where I am doing this, the blue divs would be pics (akin to thumbnails) that can be clicked. I want them to go all the way across:
/ScreenShot2013-01-09at85450PM_zps550e8e4a.png[/IMG]
Here's a fiddle:
http://jsfiddle.net/pureux/Er9eG/
You need a container for your gridPics and have it be absolute positioned (instead of the gridPics) at the bottom. Then float the gridPics inside of the container.
.picContainer {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
min-height: 50px;
}
.gridPics {
width: 50px;
height: 50px;
float: left;
display: block;
margin-right: 4px;
margin-top: 4px;
}
Is this what you're trying to do:DEMO
HTML
<div class="row-fluid">
<div class="span8 offset2 articleContent">
<div class="gridPics"></div>
<div class="gridPics"></div>
<div class="clear"></div>
<img id="sidePic" src="img/about/aboutHeader_Mid1.png" alt="about">
</div>
<div class="span2"></div>
</div>
CSS
.gridPics{
width: 10%;
height: 20px;
background: #0000b3;
float: left;
border:solid #FFF 1px;
}
.articleContent{
box-shadow: 0 0 5px 5px #888;
}
#sidePic{
z-index: -1;
}