Stack bootstrap buttons properly - html

So I was making my personal website, and decided to add resume view (google drive link) and resume download option. So I added buttons, and attached glyphicons to them, and used some custom css to make them fit with the find easter eggs button.
I coded on my PC and was happy with the results, but I suddenly remembered that phones might not handle it properly and I was right.
^ This is ok
^ This I need to fix but can't understand how.
Code for the header:
<header>
<div class="container">
<div class="intro-text">
<div class="intro-lead-in">Hey There!</div>
<div class="intro-heading">It's Nice To Meet You</div>
<div class="btn-group"></div>
Find easter eggs
<!-- <button type="button" class="btn btn-primary btn-xl"> -->
<button type="button" class="btn btn-lg btn-primary padbtn" id='vr'>
<span class="glyphicon glyphicon-eye-open"></span>
</button>
<!-- ISSUE HERE!! -->
<!-- <i class="fa fa-at fa-stack-1x fa-inverse"></i> -->
<a download="Resume_Ayush_Mandowara.pdf" href="\pdf\RESUME_14_6_17.pdf"><button type="button" class="btn btn-lg btn-primary padbtn" id='dr'>
<span class="glyphicon glyphicon-cloud-download"></span>
</button></a>
</div>
</div>
</header>
CSS applied to download and view buttons:
.padbtn
{
padding: 1.1em;
}
I want to stick the view and download buttons together, and make it look not so horrible, any help is appreciated! Thanks!

Since you're using Bootstrap you could use the column classes but this appears to be more of a one off and the columns might not provide the spacing/layout you're looking for.
I would wrap the two buttons that you want grouped in another element. Then add a media query to switch between inline and block display. Setting the grouping element to display: block; will move it below the Easter Egg button.
Here's a simplified example.
.my-btns {
text-align: center;
}
#media ( min-width: 481px ) {
.my-btn-group {
display: inline-block;
}
}
<div class="my-btns">
<button>Easter Eggs</button>
<div class="my-btn-group">
<button>1</button>
<button>2</button>
</div>
</div>

Related

HTML/CSS/Blazor Fixed Buttons above and below list which needs to fill remaining space

I have an app built in blazor for a shopping list.
The UI is composed of the default blazor template tab,
an Add Item button at the top and a Finished shopping button at the bottom.
Between the 2 buttons I want the remaining space to be taken up by a list of custom components.
I do not know how to get the height of the list set to the remaining space on the page.
Closest I have gotten is by setting the size of the list container to 100vh - 140pixels where 140pixels is the size of the buttons.
As the nav tab appears on the top for narrow screens and the left for wide screens I can't just hardcode in the value for it.
I would also prefer if this didn't rely on me hardcoding this as well.
I have tried setting the container height to 100% but that is just giving it no limit.
The list is in a div with the overflow-auto class from bootstrap.
The code
<body style="height:100%">
<div style="">
<div style="">
<button class="btn btn-primary" style="margin-bottom: 10px; width:100%;" #onclick="AddItem">Add Item <span class="oi oi-plus" style="margin-left: 5px;" aria-hidden="true"></span> </button>
</div>
<div class="overflow-auto" style="height: calc(100vh - 140px);">
#foreach (var item in _shoppingItems)
{
<ShoppingItemComponent Item="#item" DeleteItem="DeleteItem" BoughtToggle="UpdateItem" ></ShoppingItemComponent>
}
</div>
<div style="">
<button class="btn btn-primary" style="width:100%;" #onclick="ClearList">Shopping Done</button>
</div>
</div>
</body>
You can see it running here, although note I am fiddling with it there so it may not match exactly with the styling in this question.
https://smartshoppingapp.azurewebsites.net/
I have found some solutions around stack overflow around the problem, however I cannot get them working within my solution, I think all of the blazor boilerplate divs and bodies etc that wrap around my page are preventing the 100% height working as intended. i.e index.html and mainlayout.razor
Use bootstrap flex:
I un-wired your buttons to get it to work locally.
<div class="vh-100 d-flex flex-column align-items-stretch">
<button class="btn btn-primary">
Add Item <span class="oi oi-plus" style="margin-left: 5px;" aria-hidden="true"></span>
</button>
<div class="flex-fill overflow-auto">
#foreach (var item in _shoppingItems)
{
<ShoppingItemComponent Item="#item"
DeleteItem="DeleteItem"
BoughtToggle="UpdateItem" />
}
</div>
<button class="btn btn-primary">
Shopping Done
</button>
</div>
As a side note: When I am debugging these sort of issues I assign background colours to the divs to see what is really happening. That and inpecting the HTML with the browser tools.

How can i make the navbar menu options to move in the right side?

Kindly help and let me know where am i making the mistake as i can not make the options in the navbar go into the right side. Here i am sharing the code.
<div>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" style="padding-left: 40px; padding-right: 40px;">
<div style="float: left;">
<a class="navbar-brand" href="homePage.php">Job Portal</a>
</div>
<div class="topnav-right" style="float: right;">
<a href="homePage.php">
<button class="btn btn-outline-success" type="button" >
Home
</button>
</a>
<a href="signinPageOfJobSeekers.php">
<button class="btn btn-outline-success" type="button">
Sign In or Sign up
</button>
</a>
<button class="btn btn-outline-success" type="button">
Contact Us
</button>
<?php if(!empty($_SESSION['userName'])){ ?>
<a href="logOut.php">
<button class="btn btn-outline-success" type="button">
Log Out
</button>
</a>
<?php } ?>
</div>
</nav>
</div>
Your code is not enough to give you a perfect solution. However, here is my shot:
I assume that the wrapper container <div> ... </div> you have spans 100% of the viewport width? If this is the case, you can add the following style attribute:
<div style="display: flex; justify-content: flex-end;">
<nav>
// rest of the HTML code in your example
</nav>
</div>
Of course, for a cleaner solution, instead of adding an inline style attribute, you can add a CSS class and style it in a separate stylesheet file or style tag in your document <head>:
<div class="nav-wrapper">
<nav>
// rest of the HTML code in your example
</nav>
</div>
and then in your CSS declarations
.navWrapper {
display: flex;
justify-content: flex-end;
}
Alternative solution
If you are okay with your navigation overlapping the rest of the page content, you can always position: fix it. This way it would be taken out of the document flow and overlayed on top of the other HTML elements on your page. Here is the CSS needed:
.nav-wrapper {
position: fixed;
top: 0px;
right: 0px;
z-index: 999; // <- increase this value if any elements are on top of your nav
}
Have you considered using a flex box?
https://www.youtube.com/watch?v=K74l26pE4YA
Flex box is super useful for things like positioning and layout of items in a list. Check out some of the ways you can justify content: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content
Also, each individual, item can be aligned with align-self.
It's a fairly powerful way or organizing content. We can't see all of your css at the time of answering this question, but I'd take a look at the first video if you aren't already using a flexbox or to see how it works if you have a bug with one. It might work for you in this case!

Aligning text inside a Bootstrap button

I noticed there are similar questions however I tried the given solutions and nothing worked *
My custom CSS file is 100% linked correctly to the html file I'm working on *
I'm using Bootstrap v4.3.1 *
So as the title suggests, I'm trying to align text inside a Bootstrap button - I need to do that using my own custom CSS file.
I've created my new style.css file and linked it in the header (AFTER the Bootstrap CSS link), then I added a custom class (btn1) to my Bootstrap button:
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn1" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
I then added the following code in my CSS:
.btn1{
text-align: left !important;
}
But the text on the button is still not aligned to the left. Any insights as for why it happens, and ways to solve the problem?
Thanks!
You will need to change the padding on your custom css to 0, as this is still picking up the bootstrap padding. Then you can set the width to whatever size you like and add custom padding if you wanted.
Example:
.btn1{
text-align: left !important;
padding: 0;
width: 50px;
}
Buttons in bootstrap are inline-block elements and do not have defined width. Therefore, text-align: left does not work.
You need to specify width of it explicitly and use align-left. And if you need to remove event the left padding, use pl-0.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container mt-5">
<div class="row">
<div class="col">
<button class="btn btn-primary pl-0">Button</button>
</div>
<div class="col">
<button class="btn btn-primary w-100 text-left">Button</button>
</div>
<div class="col">
<button class="btn btn-primary pl-0 w-100 text-left">Button</button>
</div>
</div>
</div>
https://codepen.io/anon/pen/MMgxKz
Try this way 👇
.btn.btn1{
text-align: left;
min-width:250px;
}
note this way you don't need to add !important

Bootstrap floating drops item onto second line

This is my code: http://www.bootply.com/Tm5C3Ja7RL
<div class="col-md-12">
<h3>Test</h3><button class="btn btn-default pull-right">Button</button>
</div>
It drops the button onto a second line as well as aligning it to the right. I only want to push it to the right. Can anyone show me the best way of doing this.
As EWit mentioned, a header is a block element.
This block will push down other elements behind it.
There are several solutions, one better/cleaner than the other
Changing the header to an inline element
h3 {
display:inline;
}
This will result in your title with the button right next to it.
I don't think the pull-right will have an effect on it. Should be tested.
You could also add the condition that the h3 must have a certain class or must be inside an element with a certain class.
Splitting the column in 2
<div class="col-md-10">
<h3>Test</h3>
</div>
<div class="col-md-2">
<button class="btn btn-default pull-right">Button</button>
</div>
By also using col-sm, for example, you could alter this so that the button is displayed next to the title in a medium/large screen and under it in a small screen.
However, the pull-right might make it look pretty weird then.
<div class="col-md-10 cold-sm-12">
<h3>Test</h3>
</div>
<div class="col-md-2 col-sm-12">
<button class="btn btn-default pull-right">Button</button>
</div>
Put the button in the h3-element
As EWit mentioned, you can also put the button inside the h3-element.
This will keep the button in the same line, but might alter the text formatting.
<div class="col-md-10">
<h3>Test <button class="btn btn-default pull-right">Button</button></h3>
</div>
Put it inside the <h3>. Headers in HTML take up the full width as a block object. As such other objects are pushed down.
Try:
<div class="col-md-12">
<h3>Test <button class="btn btn-default pull-right">Button</button></h3>
</div>
I myself extend it with some markup for basic links but to align it to the same height as the text in the header.
h1 .pull-right {
padding: 15px 5px 0 0;
}
But I have no idea what values would be best for a button to align it. Trial and error I guess.

Vertical align of inline HTML elements

I know there is tons of questions (1,2,3,4,5) about inline elements I couldn't make it.
In Twitter Bootstrap I have an alert row, but the bell icon in right side isn't vertically aligned with the text in left side. Icon appears lower than the text. I tried vertical-align:middle; .row line-height etc. I also need the solution be responsive in mobile screens.
You can see my tryouts in fiddle: http://jsfiddle.net/mavent/DdLED/37/
<div class="alert alert-warning ">Today many things happened <span class="badge badge-info">121</span>
<div class="pull-right"><a class="btn btn-lg" data-toggle="collapse" data-target="#myTable"><i class="glyphicon glyphicon-bell"></i></a>
</div>
</div>
Edit: Solution:
I solved issue like the example 8 in fiddle: http://jsfiddle.net/mavent/DdLED/45/
Would this work for you? (I know, a bit of a hack)
[ CSS ]
.bring_it_up {
margin-top: -3px;
}
[ HTML ]
<!-- part 8 -->
<div class="alert alert-warning border2 "><span class="border">Today many things happened Part 8</span><span class="border badge badge-info">121</span>
<a class="bring_it_up no_padding pull-right btn btn-lg" data-toggle="collapse" data-target="#myTable"><i class="no_padding glyphicon glyphicon-bell"></i>
</a>
</div>