Bootstrap 4 Button to the right issue - html

I'm new to Bootstrap 4 and I'm designing a very simple page using Bootstrap 4. I created a NAV where I need a logo and company name to the left (this is working) and I need two button to the right of the NAV. I've found many suggestion in forums, but none seem to work for me. I'm stuck.
This is my HTML code:
<nav class="navbar bg-avesta-blue">
<div class="row">
<div class="col-sm-12">
<a class="navbar-brand text-light" href="#">
<img src="images/header-logo.png" class="float-left d-inline-block align-top pr-3" alt="">
<h3 class="pt-1">
AVESTA
</h3>
</a>
<div class="float-right text-right">
<a class="btn btn-success btn-lg text-light"><i class="fa fa-usd"></i> Sell Miles</a>
<a class="btn btn-success btn-lg text-light"><i class="fa fa-usd"></i> Sell Miles</a>
</div>
</div>
</div>
Here is what it looks like right now:
As you can see, both buttons are aligned to the left. I need them to the right.

The Navbar has supported content, and the grid row>col aren't designed to be used inside the Navbar. Read and follow the documentation.
When you use .row inside the flexbox Navbar it will not be full-width as usual and will "shrink" to the left side. You can set w-100 to make the row full-width, but the better approach is to use the supported Navbar content as intended.
"Use our spacing and flex utility classes for controlling spacing and
alignment within navbars"
https://www.codeply.com/go/Ce7CVrR5rZ
<nav class="navbar bg-avesta-blue">
<a class="navbar-brand text-light" href="#">
<img src="images/header-logo.png" class="float-left d-inline-block align-top pr-3" alt="">
<h3 class="pt-1">
AVESTA
</h3>
</a>
<div class="ml-auto">
<a class="btn btn-success btn-lg text-light"><i class="fa fa-usd"></i> Sell Miles</a>
<a class="btn btn-success btn-lg text-light"><i class="fa fa-usd"></i> Sell Miles</a>
</div>
</nav>
Once you have the correct Navbar structure, alignment can be done using auto-margins or flexbox utilities as explained in the other related questions

Related

How can I make Bootstrap 5 grids responsive to smartphones?

I have a projects section part of my portfolio. I alternate between description on left/image on right to image on left/description on right. I have been painstakingly trying to make this responsive, but I cannot think of what to do to fix this. I want the image on top and the text below on every project when viewed on a smartphone.
This is the HTML for the projects section:
<section id="projects">
<div class="container">
<div class="row projects">
<h1>My Projects</h1>
<div class="col project-desc-left">
<h2>Tindog</h2>
<p>An landing page for the Tindog app. A twist on a typical dating app. Created with Bootstrap 5 and HTML/CSS utilizing Bootstrap grids.</p>
<i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> <i class="fab fa-bootstrap"></i><br>
<a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/TinDog-WebDevBootcamp/" role="button" target="_blank">Live Site</a>
<a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/TinDog-WebDevBootcamp" role="button" target="_blank">Github Repo</a> </div>
<div class="col col-lg-6 col-sm-12 project-img-right">
<img class="project-img" src="assets/tindog.png"/>
</div>
</div>
<div class="row projects">
<div class="col">
<img class="project-img" src="assets/nftcard.png"/>
</div>
<div class="col project-desc-right">
<h2>NFT Preview Card</h2>
<p>An preview card page created with HTML/CSS.</p>
<i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> <br>
<a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/nft-preview-card-component-main/" role="button" target="_blank">Live Site</a>
<a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/nft-preview-card-component-main" role="button" target="_blank">Github Repo</a> </div>
</div>
<div class="row projects">
<div class="col project-desc-left">
<h2>3-Card Column</h2>
<p>A preview card of vehicle options created with HTML/CSS.</p>
<i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> </i><br>
<a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/3-column-preview-card-component-main/" role="button" target="_blank">Live Site</a>
<a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/3-column-preview-card-component-main" role="button" target="_blank">Github Repo</a>
</div>
<div class="col project-img-right">
<img class="project-img" src="assets/3colcard.png"/>
</div>
</div>
</div>
</section>
I used Bootstrap 5 and I tried to use col-xs-12 but it didn't look right and it also completely messed up the desktop view. The laptop view looks exactly how I want it to look, it's just every other sizing that it completely wrong.
This is the CSS:
/* Projects */
#projects {
width: 100%;
}
#projects h1 {
text-align: center;
}
.projects {
margin-left: 0;
}
.project-img{
width: 300px;
}
.project-desc-left {
margin: 5rem;
width: 320px;
}
.project-desc-right {
}
}
I have been trying to tweak the code for days, but I have barely made any progress.
This is the laptop view of the projects section
This is the mobile view of the projects section
You should be able to do it using Bootstrap 5 Column Ordering without adding any extra CSS. You can add these classes to your Col's and they will appear on the page in the order given no matter their physical place in your HTML.
General useage.
.order-1
.order-2
.order-3
.order-4
.order-5
Ordering according to screen size. In this exammple, the Column will show 1st on SM screens, it will show second on MD screens and third on LG screens.
.order-sm-1
.order-md-2
.order-lg-3 etc etc etc
You can also specify items to be unordered or ordered-first and ordered-last. Here are the docs for everything here....
https://getbootstrap.com/docs/5.0/layout/columns/#order-classes

Align center a div and align right another div in the same row

I have 3 divs, I want to align "div2" to the center of the page and "div3" at the end while being in the same row.
I've been trying some things like the "d-flex justify-content-center" that I'm currently using or making "div1" a row and giving "div3" the class "ml-auto" but then I don't know how to align "div1" to the center.
I'm using Bootstrap 5.
My actual result
<div class="text-center mt-2" id="div1">
<div class="d-flex justify-content-center" id="div2">
<a class="btn btn-lg btn-success" href="#"> Link 1 </a>
</div>
<div class="d-flex justify-content-end" id="div3">
<a class="btn btn-lg btn-info" href="#"> Link 2 </a>
<a class="btn btn-lg btn-info" href="#"> Link 3 </a>
</div>
</div>
One way is to use nested flexbox items. For this you'll need an empty spacer for the left, and each child item needs flex: 1:
.flex1 {
flex: 1;
}
<div class="text-center mt-2 d-flex w-100" id="div1">
<div class="d-flex flex1"><!--spacer --></div>
<div class="d-flex flex1 justify-content-center" id="div2">
<a class="btn btn-lg btn-success" href="#"> Link 1 </a>
</div>
<div class="d-flex flex1 justify-content-end" id="div3">
<a class="btn btn-lg btn-info" href="#"> Link 2 </a>
<a class="btn btn-lg btn-info" href="#"> Link 3 </a>
</div>
</div>
dead center using flexbox nesting
Another way is to use absolute position:
<div class="text-center mt-2 d-flex justify-content-center" id="div1">
<div class="d-flex" id="div2">
<a class="btn btn-lg btn-success" href="#"> Link 1 </a>
</div>
<div class="ms-auto position-absolute end-0" id="div3">
<a class="btn btn-lg btn-info" href="#"> Link 2 </a>
<a class="btn btn-lg btn-info" href="#"> Link 3 </a>
</div>
</div>
dead center using absolute position
Read more: aligning flexbox items is explained here
This solution should help you:
div2 is in the center of the row
div3 is at the end of the row
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex justify-content-end" id="div1">
<div id="div2" class="position-absolute" style="left:50%;width:100px;margin-left:-50px">
<a class="btn btn-lg btn-success" href="#"> Link 1 </a>
</div>
<div id="div3">
<a class="btn btn-lg btn-info" href="#"> Link 2 </a>
<a class="btn btn-lg btn-info" href="#"> Link 3 </a>
</div>
</div>

Fitting elements for Splash Page on mobile in BootStrap

I'm trying to create a responsive splash page, but it's not responding, no matter how much I try to manipulate it. What I'm mostly trying to do is fit the image with no margin or padding. I want it similar to Adele's mobile site. Also, I'm not sure if the code is clean and I'm naming the classes correctly. I created a codepen so you can check it out there.
<div class="featurette">
<img class="featurette-image img-responsive pull-left center-block" src="http://www.placehold.it/400/F84065/000" alt="#">
<div class="purchase-album">
<div class="album">
<img class="img-responsive" src="http://www.placehold.it/200/fa8ca2" />
<div class="lead">available now:</div>
</div>
<div class="space">
</div>
<p class="lead text-center available "></p>
<a href="#" target="_blank">
<button type="button" class="btn btn-default btn-lg outline" type="submit">iTunes</button>
</a>
<a href="#" target="_blank">
<button class="btn btn-default btn-lg outline" type="submit">loudr</button>
</a>
</div>
</div>
<div class="enter">
<button type="button" class="btn btn-default btn-lg outline" type="submit">
enter
</button>
</div>
</div>
Adeles page is a background image with the content displayed on top.
You can achieve this in many ways.
Try using this and playing about with the CSS to get everything in the desired place.
codepen here example
<header>
<div class="overlay">
<div class="header-content">
<div class="header-content-inner">
<h1>Your image here</h1>
<p>buttons here etc</p>
</div>
</div>
</div>
Shrink the page to see the responsive-ness

Trying to line up text under Font Awesome icon

I'm currently using 2 Font Awesome icons. The problem is that I want to add text under each one that align with these icons. The problem is that the text is centered on the page but not under the corresponding icons.
Code:
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1 class="brand-heading">Title</h1>
<p class="intro-text">description</p>
<a href="#about" class="btn btn-circle page-scroll btn-lg">
<i class="fa fa-angle-double-down animated"></i>
</a>
<a href="#contact" class="btn btn-circle page-scroll">
<i class="fa fa-angle-double-up animated"></i>
</a>
</div>
</div>About Contact
</div>
I think this is what you want to do. Here is the fiddle:
http://jsfiddle.net/plushyObject/02s7wnm8/
<div class="col-md-8 col-md-offset-2 text-center outline">
<h1 class="brand-heading">Title</h1>
<p class="intro-text">description</p>
<div class="col-sm-4 outline">
<a href="#about" class="btn btn-circle page-scroll btn-lg outline">
<i class="fa fa-angle-double-down fa-fw"></i>
</a>
<p class="outline">
Text is centered by 'text-center' class inherited from first
column.
</p>
</div>
</div>
If you text-align the parent element, it will be inherited by the picture.
CSS
.container {
text-align: center;
}
Line it up using an HTML <table>, and style it with CSS. That way it will stay on top of the icons correctly.
http://jsfiddle.net/vd6smL75/

Bootstrap v3 ROW of "href buttons" works in JSFiddle but creates a STACK of buttons on my webpage

Using bootstrap v3 the goal is to create a row of fixed width href buttons for navigation. The code, using nothing but bootstrap styled HTML, achieves this in JSFiddle using
.nav_btn
{
width: 82px !important;
margin-right: 5px;
}
<div class="col-md-10">
<div class="btn-toolbar">
<div class="btn-group">
<a href="#" class="btn btn-default nav_btn" disabled>
<span><strong>Portfolio</strong></span>
</a>
<a href="#" class="btn btn-primary nav_btn">
<span><strong>Quote</strong></span>
</a>
<a href="#" class="btn btn-success nav_btn">
<span><strong>BUY</strong></span>
</a>
<a href="#" class="btn btn-success nav_btn">
<span><strong>SELL</strong></span>
</a>
<a href="#" class="btn btn-info nav_btn">
<span><strong>History</strong></span>
</a>
</div>
</div>
</div>
http://jsfiddle.net/SBSgN/12/
The exact code shown, with custom .nav_btn styling as shown, displays the buttons... stacked vertically :( when inserted into HTML for an actual web page. The code is inside a container. No other div specifying a grid size (e.g. col-md-10) appears before the code in question.
What am I missing.