Trying to build a new site using Bootstrap-4
I'm trying to align a logo to the left, a link button in the center and a link button to the right of a footer div. At the moment, I've got it working except the logo is vertically aligned so that its top is middled rather than the center of the image, so its hanging low!
I've tried vertical aligning it and experimented with justify contents settings.
.footer {
background-color: #68B3E2;
text-align: center;
padding: 30px;
justify-content: space-around;
}
.logo {
display:inline-block;
float:left;
}
.center_btn {
display:inline-block;
float:none;
}
.right_btn {
display:inline-block;
float:right;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="footer">
<img class=logo src="images/logo.png" width="120" height="120" alt="">
<a class="center_btn btn-primary btn-lg" href="#" role="button">Ask a question</a>
<a class="right_btn btn-primary btn-lg" href="#" role="button">Register</a>
</div>
This is simpler using the Bootstrap flexbox util classes (no need for all the extra CSS)...
<div class="footer d-flex justify-content-between align-items-center">
<img class=logo src="//placehold.it/120" width="120" height="120" alt="">
<a class="center_btn btn-primary btn-lg" href="#" role="button">Ask a question</a>
<a class="right_btn btn-primary btn-lg" href="#" role="button">Register</a>
</div>
https://codeply.com/p/QpjEZtn11G
Good day! Just use Flexbox CSS, keep it simple.
.footer {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
background-color: #68B3E2;
padding: 30px;
}
<div class="footer">
<img class=logo src="https://avatars.mds.yandex.net/get-pdb/2978990/ac5c48be-c30e-4595-9f4b-72fa8d31addb/s375" width="120" height="120" alt="">
<a class="center_btn btn-primary btn-lg" href="#" role="button">Ask a question</a>
<a class="right_btn btn-primary btn-lg" href="#" role="button">Register</a>
</div>
Related
I need the left block to the left side of my footer and the right block to the right side of my footer. But for some reason both are underneath. Any help would be appreciated!
I tried a few things but didnt work and chatgpt wont give me the proper solution.
Below I inserted html and css, maybe someone could help me with this, would be nice.
.mastfoot .inner {
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
.mastfoot .inner>div {
width: 25%;
}
.mastfoot .inner>div>a {
margin-right: 10px;
margin-bottom: 10px;
text-align: center;
}
.mastfoot .inner>div>a {
display: block;
}
.mastfoot .inner>div {
padding: 10px;
}
.d-flex {
display: flex;
flex-direction: column;
}
.btnfooter {
display: block;
margin-bottom: 5px;
}
.left-block {
justify-content: flex-start;
}
.right-block {
justify-content: flex-end;
}
<footer class="mastfoot mt-auto">
<div class="inner d-flex justify-content-between">
<div class="d-flex left-block">
<div>
<h4>Left Block</h4>
</div>
<div>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
</div>
</div>
</div>
<div class="inner d-flex justify-content-between">
<div class="d-flex right-block">
<div>
<h4>Right Block</h4>
</div>
<div>
<a class="btn btnfooter btn-outline-warning btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-warning btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-warning btn-sm" href="#" target="_blank">.....</a>
</div>
</div>
</div>
</footer>
Please note that to simplify the code I removed some list items but they all have class="footerstyle"
This is what the list currently looks like:
This is what I want it to look like however they have to be in the centre of a bootstrap grid:
This is my code:
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
}
footer {
position: relative;
}
.list-unstyled {
margin-bottom: 20px;
}
.footerstyle {
font-size: 18px;
text-align: center;
}
.footerstyle:hover {
border-radius: 25px;
text-align: center;
border-bottom:solid 1px transparent;
}
.dropright {
flex-wrap: wrap;
}
.col-md {
height: 200px;
display: flex;
}
<div class='footer'>
<footer class="page-footer font-small pt-4">
<div class="row">
<div class="col-sm">
<ul class="list-unstyled">
<div class="col-sm">
</div>
<div class="col-sm">
<li class="footerstyle">
<a>Homepage</a>
</li>
</div>
<div class="col-sm">
<div class="dropdown footerstyle">
<a class="footer-dropdown dropdown-toggle" id="dropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Team
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" >Team members</a>
<a class="dropdown-item" >Our Story</a>
<a class="dropdown-item" >Join the team</a>
</div>
</div>
</div>
</ul>
</div>
<div class="col-sm socialmedia">
<a href="">
<img src="linkedin.png">
</a>
<a href="">
<img src="twitter.png">
</a>
</div>
<div class="col-sm cookies">
A
</div>
</div>
<div class="footer-copyright text-center py-3">
<a> B </a>
</div>
</footer>
</div
The other items in the footer are in the right place and don't have this problem as they aren't list items. How can I make it so that the list items align to the left whist still being on the centre of the bootstrap grid?
To align text left just add this code to your css:
.page-footer a {
text-align:left;
}
The image and buttons are inside a div. How can i make the image occupy the whole div with buttons on the top right corner on the image?
This is the div that contains two buttons and an image. How can i place the two buttons on the top right corner of the image?
I tried to do position:relative;top:25px but the button will behind the image
<div class="image">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
<img src="{{ $image->image }}" class="img img-responsive full-width">
</div>
Use relative and absolute like shown below to achieve the desired effect.
P.S: I have used T and P to denote the icons as they were not visible in the snippet.
.image {
position: relative;
display: inline-block;
}
.overlay {
position: absolute;
right: 0;
z-index: 5;
}
<div class="image">
<div class="overlay">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
T<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
P<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
</div>
<img src="https://picsum.photos/200" class="img img-responsive full-width">
</div>
Please try this code. Use Position relative and absolute like this:
.image {
position: relative;
}
.image .delete-image-btn,
.image .edit-image-btn {
position: absolute;
top: 0;
right: 0;
z-index: 1;
}
.image .edit-image-btn {
margin-right: 40px;
}
Though there are many ways, a simple solution would be to give the buttons a z-index property.
.delete-image {
z-index :1;
}
.image {
position: relative;
}
.image .actions {
right: 1em;
top: 1em;
display: block;
position: absolute;
}
.image .actions a {
display: inline-block;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="image">
<div class="actions">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
</div>
<img src="https://cdn.pixabay.com/photo/2013/07/12/17/47/test-pattern-152459_960_720.png" class="img img-responsive full-width">
</div>
This is the html I'm working with (which I cannot change):
<div class="article-summary media">
<div class="media-body">
<h3 class="media-heading">
<a href="">
Boosting SRL for Recommendation Systems
</a>
</h3>
<div class="meta">
<div class="authors">
Kaushik Roy
</div>
</div>
<div class="btn-group" role="group">
<a class="galley-link btn btn-default role=" button"="" file"="" href="">
PDF
</a>
<a class="galley-link btn btn-default role=" button"="" file"="" href="">
XML
</a>
</div>
</div>
<div class="media-body">
....
</div>
</div>
This is what it looks like now
This is how I want it to look
I'm trying to push the PDF|XML btn-group to the upper right. If the h3.media-heading is long, it should stop short of the btn-group and continue on the next line instead of pushing the btn-group down
Here's my current solution but I'm not sure if there are any side-effects I'm not thinking of
.media-body {
position: relative;
}
.media-heading {
float: left;
padding-right: 150px;
}
.meta {
float: left;
clear: left;
}
.media-body > div.btn-group {
position: absolute;
right: 0;
}
Basically, I float all the .media-heading and .meta to the left, and I try to use absolute position to place the btn-group. I add a relative position to the btn-group's container, which is the .media-body because I learned that helps contain the absolute positioning of the element, otherwise, it flies out of the container and to the right of the entire page.
I'd really appreciate some help on an issue i'm having.
For reference: http://trs-studios.com/test
I'm trying to get the 3 boxes (side to side) to align to the center of the page.
<div class="wrapper">
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank"></i> MEDIA</a>
<div class="spacer"/>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank"></i> STUDIO</a>
<div class="spacer"/>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank"></i> DESIGN</a>
</div>
Css for wrapper
.wrapper {
padding-top: 100px;
text-align: center;
}
Css for spacer
.spacer {
display: inline;
margin: 50px 50px;
position: relative;
text-align: center;
}
I'd appreciate any help!
Forget those spacing divs, HTML is not for styling.
Using display: inline-block on your links, you can simply put margin on them.
HTML:
<div class="wrapper">
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank">MEDIA</a>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank">STUDIO</a>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank">DESIGN</a>
</div>
CSS:
.wrapper {
text-align: center;
}
.wrapper .btn {
display: inline-block;
margin: 50px 25px;
}
Working demo