Align two buttons at the bottom of the page - css

I have to align two buttons at the bottom of the page, but I can not do it. One is the button "gallery" and the other is icon linkedin.
<div class="container fill">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item">
<div class="fill" style="background-image:url('http://www.mysite/images/category/image.jpg');background-position: center;">
<div class="container">
<div class="carousel-caption">
<h1>TITLE</h1>
<p class="lead">Description</p>
</div>
</div>
<div class="pull-right">
<a class="btn btn-large btn-primary" href="categories.php?id=17">View Gallery</a>
</div>
</div>
</div>
</div>
<div class="pull-left">
<div class="social-caption">
<button class="btn btn-large btn-linkedin">
<i class="icon-linkedin"></i><span><a style="color:white" vhref="http://www.linkedin.com/"> | Linkedin</span></button>
</div>
css for the two buttons:
.social-caption {
background-color: transparent;
position: relative;
max-width: 100%;
padding: 0 20px;
bottom: 45px;
left: 5px;
}
.gallery-button {
background-color: transparent;
position: relative;
max-width: 100%;
padding: 0 20px;
bottom: 45px;
right: 5px;
}
The two buttons do not appear aligned. This problem is seen especially with mobile devices
Solutions? Thanks

You could do something like THIS, for example. It uses position:absolute to locate the buttons at the bottom of the page's content (bottom:0) - or relative to their parents positioning (in this case the body. The alternative would be to use position:fixed which would ensure the buttons appear at the bottom of the viewport at all times.
See the difference between absolute positioning and fixed positioning.
HTML
<button>Button 1</button>
<button>Button 2</button>
CSS
body{
position:relative;
}
button{
position:absolute;
bottom:0;
}
button:last-child{
left:100px;
}

May be you could use this:
<input type='button' style='position:fixed; top:94%; left:82%; width:100px' value='
this means the button will appear at the right corner in the bottom of your page.

//hope so this code helps you.
.center{
justify-content: center;
display:flex;
align-item: center
}
.right{
justify-content: flex-end;
display:flex;
}
//for center align
<div class="center">
<button>First Button</button>
<button>Second Button</button>
</div>
//for right align
<div class="right">
<button>First Button</button>
<button>Second Button</button>
</div>

Related

How to vertically center a button in a container

How do I vertically center my view button within the box container.
I tried styling the button with vertical-align:center; but it didn't work.
I tried adding: position: relative; top: 50%; transform: perspective(1px) translateY(-50%);.
But this just makes half of the button appear on top of the container and the other half inside the container
View:
<div class="container signup2">
<div class="title container">
<h2> Enrolled Courses: </h2>
</div>
<div class="container box">
<div class="row col-centered">
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8 index">
<h3><%= course.name %></h3>
<p><%= course.description %></p>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
<%= link_to "View", course_path(course), class: "btn button buttonmargin align" %>
</div>
</div>
</div>
</div>
custom.scss:
.signup2 {
margin-top: 120px;
}
.title {
margin-bottom: 15px;
}
.box {
background-color: #f7f7f7;
margin-bottom: 20px;
}
.index {
text-align: left;
}
.align {
position: relative;
top: 50%;
transform: perspective(1px) translateY(-50%);
}
.button {
background-color: #20B2AA;
color: white;
}
.buttonmargin {
margin-left: 150px;
}
This is how it looks like
Try using flex.
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 align"> //moved align class here
<%= link_to "View", course_path(course), class: "btn button buttonmargin" %>
</div>
And css for align :
.align {
display: flex;
justify-content: center;
align-items: center;
}
Here is codesandbox link
Shubham's answer is almost correct. However, the css class that needs to have a display:flex property is actually on the row itself. Instead of modifying the CSS, Bootstrap 4.0 has a built-in class called .d-flex that you can pair with .align-items-center and it will work. See examples below:
With no defined height properties:
<div class="container">
<div class="row d-flex align-items-center">
<div class="col-12">
Anything in here will be vertically centered
</div>
</div>
</div>
With a defined height property on the container:
<div class="container d-flex align-items-center" style="height:500px">
<div class="row">
<div class="col-12">
Anything in here will be vertically centered
</div>
</div>
</div>

Unable to align divs properly with background image size cover using bootstrap

I'm making a website with angular, bootstrap and i need the first view to be background entirely and then user can scroll down to next div but i am having trouble aligning the divs properly all day
Tried to use an img element with block size but it didn't work, tried to use padding but that completely breaks site on mobile and other size screens
Home component:
<div>
<div id="home-bg-img"></div>
<div id="home-main">
<div class="col-md-12 landing text-center my-auto">
<h2 class="h2 text-light"><span class="purple">ProjectName</span></h2>
<h3 class="h3 cosmic-purple">An Intuitive, Secure and Reliable Project.</h3>
<a class="btn btn-primary btn-lg" href="#" role="button">Explore The Project</a>
</div>
</div>
<div class="container col-md-12" id="home-body">
<div class="row">
<div class="col-md-12 text-center">
<h3 class="h3">
Just some text which should be beneath the image div wberjk vbetba jvntenb jtjrbsb teb jte hjkbtejknb jkbtseb gsdhjjds fhjvbjhebr hjvbdhj sbvhjds
</h3>
</div>
</div>
</div>
</div>
CSS:
#home-main {
height: 100% !important;
width: 100% !important;
margin: 0;
padding: 0;
border: 0;
z-index: auto;
}
#home-bg-img{
position: absolute;
min-height: 100%;
min-width: 100%;
background-image: url("./assets/laura-skinner-348001-unsplash.jpg");
background-size: cover;
background-position-x: center;
background-repeat: no-repeat;
}
I get the image aligned properly in the bg but the two DIVs are at the top of the page one after another
What i want to do is to have the text of first DIV in the center of page (horizontally and vertically) and the second div's text after the bg image after a scroll down
You need to put the content which should be in front of the image in the same <div> where the background image is applied. Also, lose the position: absolute property and I have added display: flex to center the text vertically and horizontally.
html,
body {
height: 100%;
}
#parent-container {
height: 100%;
}
#home-main {
height: 100%;
width: 100%;
}
#home-bg-img {
display: flex;
min-height: 100%;
min-width: 100%;
background-image: url("https://placeholdit.imgix.net/~text?txtsize=63&bg=FF6347&txtclr=ffffff&txt=Image-1&w=350&h=250");
background-size: cover;
background-repeat: no-repeat;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet" />
<div id="parent-container">
<div id="home-bg-img">
<div class="col-md-12 landing text-center my-auto">
<h2 class="h2 text-light"><span class="purple">ProjectName</span></h2>
<h3 class="h3 cosmic-purple">An Intuitive, Secure and Reliable Project.</h3>
<a class="btn btn-primary btn-lg" href="#" role="button">Explore The Project</a>
</div>
</div>
</div>
<div id="home-main">
<div class="container col-md-12" id="home-body">
<div class="row">
<div class="col-md-12 text-center">
<h3 class="h3">
Just some text which should be beneath the image div wberjk vbetba jvntenb jtjrbsb teb jte hjkbtejknb jkbtseb gsdhjjds fhjvbjhebr hjvbdhj sbvhjds
</h3>
</div>
</div>
</div>
</div>

How do I make modal buttons appear inside the modal body?

How do I make modal buttons ("OK", "DISMISS", etc) appear inside the modal body instead of the footer?
Because I set a photo as a background I'd like the buttons floating above this photo.
<div class="container">
<div class="modal1 fade"
id="XXX"
tabindex="-1"
aria-labelledby="XXX"
role="dialog"
aria-hidden="true">
<div class="modal_wrapper1">
<div class="modal-dialog1">
<div class="modal-body">
<img class="img-responsive" src="Ximage" alt="image" />
button!
Close
</div>
</div>
</div>
</div>
</div>
.modal1{
width: 100%;
position: fixed;
text-align: center;
margin: 0px auto; top: 0px;
left: 0px; bottom: 0px; right: 0px;
z-index: 1050;
}
.modal_wrapper1{
display: table;
overflow: auto;
overflow-y: scroll;
height: 100%;
-webkit-overflow-scrolling: touch; outline: 0;
text-align: center;
margin: 0px auto;
}
.modal-dialog1{
margin-top: 0px;
display: table-cell;
vertical-align: middle;
margin: 0px 20px;
}
I have used same thing to display button in the same section, with background and control placed on it, you can try similar to this in your page. Its working fine for me.
You can change background to apply to your section instead of body.
<body style="background-image: url('../../abc.jpg'); align-content:center;">
<header style="height:200px">
<section>
<div class="container">
<div class="row" >
<div class="col-lg-5">
</div>
<div class="col-lg-2 text-center">
<div id="login" name="loginForm" >
<input ........ /><br /><br />
<input type="submit" class="btn btn-success" value="Continue" />
</form>
</div>
<div class="col-lg-5">
</div>
</div>
</div>
</section>
</body>
If you are using bootstrap, than it will be better if you use the default css instead of modifying it too much, as it will affect the placement of controls when screen have different resolutions.
Instead of adding an <img> inside the modal-body div, apply it as a background image in your css.
.modal1 .modal-body {
background:url(Ximage) no-repeat;
background-size:contain; // or auto or cover, whichever works best.
}

Link doesn't stay on the top of the screen with the image

I have a website. And a logo which is always on the top of the screen. When you scroll down is still there, the top of the screen, you still see it. This is fine. On the top the logo image have a link, but when you scroll down, you lose it. I want the link to go with the image. I hope i was clear.
Here is the html:
<div class="col-md-12" id="menu">
<div class="col-xs-3 col-sm-2 col-md-2" id="logoparent">
<div id="logo">
<!--<h3>LOGO</h3>-->
<img src="Logo.png" id="thelogo">
</div>
</div>
<div class="col-xs-1 col-sm-2 col-md-6 space">
<!-- empty -->
</div>
<div class="col-xs-8 col-sm-2 col-md-1 menuitem" id="home">
<h3>Home</h3>
</div>
<div class="col-xs-12 col-sm-2 col-md-1 menuitem" id="gallery">
<h3>Gallery</h3>
</div>
<div class="col-xs-12 col-sm-2 col-md-1 menuitem" id="about">
<h3>About</h3>
</div>
<div class="col-xs-12 col-sm-2 col-md-1 menuitem" id="contact">
<h3>Contact</h3>
</div>
</div>
And the css:
#logo{
position: fixed;
z-index: 99;
height: 60px;
width: auto;
overflow: hidden;
margin-left: auto !important;
margin-right: auto !important;
}
#logoa{
position: relative;
z-index: 99;
}
#thelogo{
position: fixed;
z-index: 99;
height: 50px;
width: auto;
margin-top: 5px;
}
#menu{
position: relative;
z-index: 5;
}
#content-all{
position: relative;
z-index: 5; /*which is everything under the menu*/
}
I would suggest you to add a link to that logo by itself so when you click to the logo you go to the appropriate link, always if that logo has something to do with the link, otherwise add use nested DOM to style it.
You can put all menu tags in main tag and set css style for main tag like this
#menu1{
position: fixed;
top:10px;
left:10px;
height: 60px;
width:50px;
}
Check this
JSFiddle

CSS top right icon

I have a loop that shows all the users comments. I'm trying to add a trash icon on the top-right of each comment, but it's putting all the icons at the same place in one div. I don't want the icon to change the position of the comments and that's why I did position absolute, but it's not working.
Loop code:
<div class="col-md-5 all">
<div class="col-md-12 hello">
#foreach($comment as $comments)
#if($comments->image_id == $image->id)
<div id="{{$comments->id}}" class="ajaxrules">
<div class="col-md-2">
<img src="{{$comments->user_avatar}}" class="img-circle buddy">
</div>
<div class="col-md-10">
<h4>{!! $image->user_name !!}</h4>
<p class="left">{!!$comments->body!!} </p>
</div>
<div class="deletecomment">
<i class="fa fa-trash-o"></i>
</div>
</div>
#endif
#endforeach
<div class="addavatar">
</div>
</div>
</div>
css:
.deletecomment{
display: block;
position: absolute;
top: 0;
right: 0;
clear:both;
}
.addavatar, .ajaxrules{
padding-right: 60px;
padding-top: 10px;
}
You need to add position: relative
to .ajaxrules
So the trash icon will be absolute to it's parent
Edit: adding additional information on position absolute/relative
https://css-tricks.com/absolute-positioning-inside-relative-positioning/

Resources