Bootstrap Navbar Expands when Window gets smaller - html

Regular
Smaller
My bootstrap 3.0 navbar expands when the window gets to mobile sizes. I've included pictures of the two views above and where the issue is.
I am trying to get my navbar to not expand when the screen gets smaller and cover part of my page.
It may have something to do with the search bar and the buttons near it. I managed to get the search form stay the same size when it expanded across the entire screen behind the sidebar before.
Any help would be great.
HTML
`
<a class="navbar-brand" style="margin-left: -20px">GCImage</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-right">
<form class="navbar-form" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search" align="right" ng-model="nav.keyword" uib-popover="Not Implemented Yet" popover-placement="bottom" popover-trigger="focus">
</div>
<button type="submit" class="btn btn-default" align="right" uib-popover="Not Implemented Yet" popover-placement="bottom" popover-trigger="focus">
<i class="fa fa-search"></i>
</button>
<a class="btn btn-default" href="underConstruction.html"><i class="fa fa-filter"></i></a>
</form>
</div>
</div>
`
CSS
.panel-green {
border-color: #5cb85c;
background-color: #5cb85c;
color: #ffffff;
}
.panel-orange {
border-color: #ff7e47;
background-color: #ff7e47;
color: #ffffff;
}
.shadow {
-moz-box-shadow: 1px 1px 2px 3px #ccc;
-webkit-box-shadow: 1px 1px 2px 3px #ccc;
box-shadow: 1px 1px 2px 3px #ccc;
}
.panel-footer {
color: #000000;
}
.btn-file {
position: relative;
overflow: hidden;
}
.btn-file input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 100px;
text-align: right;
filter: alpha(opacity=0);
opacity: 0;
outline: none;
background: white;
cursor: inherit;
display: block;
}
.body{
margin-left:175px
}
.navbar .navbar-form{
padding: 0 15px;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.box{
border-radius:0;
}
.navbar-collapse.collapse{
display: block !important;
}
.navbar-nav>li, .navbar-nav{
float: left !important;
}
.navbar-nav.navbar-right:last-child{
margin-right: -15px !important;
}
.navbar-right{
float: right !important;
}

It looks like the icons are wrapping underneath the search bar
I played around with your code a little and came up with a solution, however the icons eventually wrap when the screen gets really small (less than 250px wide)
Try changing this code:
<button type="submit" class="btn btn-default" align="right" uib-popover="Not Implemented Yet" popover-placement="bottom" popover-trigger="focus">
<i class="fa fa-search"></i>
</button>
<a class="btn btn-default" href="underConstruction.html"><i class="fa fa-filter"></i></a>
To this code:
<div class="icons">
<ul class="icon-list">
<li class="icon">
<button type="submit" class="btn btn-default" align="right" uib-popover="Not Implemented Yet" popover-placement="bottom" popover-trigger="focus">
<i class="fa fa-search"></i>
</button>
</li>
<li class="icon">
<a class="btn btn-default" href="underConstruction.html"><i class="fa fa-filter"></i></a>
</li>
</ul>
</div>
And add this to your stylesheet:
.icons {
float: right;
}
ul.icon-list {
padding: 0px;
margin: 0px 0px 0px 4px;
}
li.icon {
display: inline;
list-style: none;
}
.form-group {
display: inline-block !important;
}
This solution isn't perfect, and could be improved (make a backup of your old code before trying this)

Just add
.navbar-header{
display: inline-block; or display: inline-block!important;
}
in your stylesheet. I hope this is what you expect. :)

Related

Cannot separate the item un-ordered list and button

I don't know how to describe this problem. I'm using three styling frameworks Bootstrap, Semantic, and Materialize CSS. I've created an unordered list after that there is a button when I use the br tag to separate them separation works but the gap doesn't fill with the body background color so I used margin but still, the gap is not filling with body color.
You can see this problem in this
HTML code
<section>
<div class="container dashboard ">
<div class="row">
<aside class="col-sm-3">
<ul class="list-group text-center">
<a class="list-group-item active" href="#">Dashboard</a>
<a class="list-group-item" href="#">All Posts</a>
<a class="list-group-item" href="#">Create/Edit Posts</a>
</ul>
<a class="btn btn-light btn-block" href="#"> <i class="fa fa-power-off"></i> <span class="text">Log out</span> </a>
</aside>
</div>
</div>
</section>
CSS
.dashboard{
margin-top: 100px;
margin-bottom: 100px;
padding: 30px 0px;
}
.dashboard .col-sm-3{
border-bottom: none;
border-radius: 5px;
height: fit-content;
padding-left: 0;
padding-right: 0;
background: #fff;
}
.dashboard .col-sm-3 ul a{
text-decoration: none;
font-weight: 500;
}
.dashboard .col-sm-3 .btn {
margin-top: 50px;
}
.btn-light {
background-color: #fff;
border-color: #e4e4e4;
text-align: center;
}
.btn-light span{
text-transform: none;
font-weight: 500;
}
You can check this question this thing will help you link
Actually, this question helps me too I've also faced a similar situation.
I will make this more simple I think this work you can try this
br {
content: "A" !important;
background: #fafafa !important;
display: block !important;
width: 100% !important;
height: 30px !important;
}

Buttons not Horizontally Aligning for Mobile

I have two buttons and they horizontally align perfectly for desktop, but they don't for mobile. I am also using MaterializeCSS if that matters.
Here is the relevant code:
html {
--global-color: white;
--global-color-invert: black;
--background-color: white;
--not-current-screen: lightgray;
--current-screen: black;
--padding-of-side: 0%;
--padding-bottom: 5%;
--margin-left: 15%;
--margin-right: 15%;
--padding-left: 0%;
--padding-right: 0%;
}
html[data-theme="dark"] {
--global-color: black;
--global-color-invert: white;
--background-color: #1A1B1C;
--not-current-screen: #787878;
--current-screen: white;
}
#media screen and (min-device-width: 0px) and (max-device-width: 600px) {
html {
--padding-of-side: 20%;
--padding-bottom: 3%;
--margin-left: 2%;
--margin-right: 2%;
--padding-left: 1%;
--padding-right: 1%;
}
}
.not_current_screen {
color: var(--not-current-screen);
border-left: 1.5px solid var(--not-current-screen);
padding-left: var(--padding-of-side);
margin-top: 2px;
}
.current_screen {
color: var(--current-screen);
border-left: 1.5px solid var(--current-screen);
padding-left: var(--padding-of-side);
margin-top: 2px;
}
body {
background-color: var(--background-color);
color: var(--global-color-invert)
}
label > span {
color: var(--global-color-invert)
}
input[type="checkbox"] {
border: 2px solid var(--global-color-invert) !important;
}
.padded_div {
border: 1px solid var(--global-color-invert);
border-radius: 5px;
padding-top: 1%;
padding-bottom: var(--padding-bottom);
margin-left: var(--margin-left);
margin-right: var(--margin-right);
padding-left: var(--padding-left);
padding-right: var(--padding-right);
text-align: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<div id="appMain" class="padded_div">
<h5>Please Agree to These Terms and Conditions:</h5>
<div class="row">
<div class="col s2">
<div>
<ul>
<li class="current_screen">Terms and Conditions</li>
<li class="not_current_screen">Patient Info</li>
<li class="not_current_screen">Suggested Symptoms</li>
<li class="not_current_screen">Symptoms</li>
<li class="not_current_screen">Diseases</li>
</ul>
</div>
</div>
<div class="col s8">
<br>
<ul style="text-align: center; list-style-position: inside;" class="browser-default">
<li>This is not a replacement for doctors.</li>
<li>This app may not be completely accurate.</li>
<li>Do not use this to actually check symptoms for patients.</li>
<li>This is a demo, we are non-liable.</li>
</ul>
<br>
<br>
<label style="text-align: center;">
<input type="checkbox" class="filled-in" />
<span>I understand</span>
</label>
</div>
</div>
<br>
<button style="margin-right: 33%" id="back" class="waves-effect waves-light btn">Back</button>
<button style="margin-left: 33%" id="next" class="waves-effect waves-light btn disabled" onclick="moveToPage(2)">Next</button>
<script>
var checkbox = document.querySelector("input[type=checkbox]");
checkbox.addEventListener('change', function() {
if (this.checked) document.getElementById("next").classList.remove("disabled");
else document.getElementById("next").classList.add("disabled");
});
</script>
</div>
Image showing broken on mobile:
If you want the website url, here: https://healthhacks2021.herokuapp.com/
Take off the margin-right:33% for the left button and margin-left:33% for the right button on mobile breakpoints and they will be side by side.
Put the buttons into SPAN, remove margins (that I think that are the problem) then encapsulate in a DIV, then set flex to it, just like this:
<div class="mybuttons">
<span><button id="back" class="waves-effect waves-light btn">Back</button></span>
<span><button id="next" class="waves-effect waves-light btn disabled" onclick="moveToPage(2)">Next</button></span>
</div>
And in CSS file:
.mybuttons {
display: flex;
justify-content: space-between;
text-align: left;
}
.mybuttons:last-child {
text-align: right;
}
Your buttons will show aligned without using margins. Maybe is not elegant... but will do.

How do i hover a icon and it displays a input

<div id='searchParent'>
<!--icon to be hovered-->
<i id="search" class="fas fa-search"></i>
<!--icon to be hovered-->
<div id="inputParent">
<!--input to be shown-->
<input type="text" placeholder='Pesquise' autocomplete='off' id="input-bar">
<!--input to be shown-->
</div>
</div>
I´ve been working in this for a really long time, and the best piece of css hover i could get was this:
#search:hover ~ #inputParent #input-bar {
width: 200px;
}
But the problem is that when you hover the input it just drag it way out and you cant just write anything.
The icons are in my local machine but i will prolably put them in there
EDIT: I´m going to show some of my poor css and what i was intending to do.
input {
border: none;
outline: none;
border-bottom: 0.3px solid black;
}
#search {
padding-left: 180px;
display: inline-block;
}
#inputParent {
margin-left: auto;
}
#input-bar {
margin-right: 1vw;
width: 0;
transition: 0.8s ease-in-out;
}
#search:hover ~ #inputParent #input-bar {
width: 200px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
</head>
<body>
<div id="searchParent">
<i id="search" class="fas fa-search"></i>
<div id="inputParent">
<input type="text" placeholder="Pesquise" autocoplete="off" id="input-bar">
</div>
</div>
</body>
</html>
What i really wanted to do was to when i hovered the input it stay there.
I really dont know why the bar is going from the left to the right, it was suposed to go backwards
Hi If you are able to add a new div to your HTML and add a class to your inputParent this is quite easy. Please see my code:
.dropdown {
position: relative;
display: inline-block;
}
#inputParent {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover #inputParent {
display: block;
}
<div id='searchParent'>
<!--icon to be hovered-->
<div class="dropdown">
<i id="search" class="fas fa-search"></i>Icon
<!--icon to be hovered-->
<div id="inputParent" class="parentc">
<!--input to be shown-->
<input type="text" placeholder='Pesquise' autocomplete='off' id="input-bar">
<!--input to be shown-->
</div>
</div>
</div>

How to add in input form button cancel

I would like to do something like this.
but i dont know how to do it in Bootstrap correctly
Here's my html code where i get only like this.
<form class="navbar-form" role="search">
<div class="input-group add-on">
<input type="text" [(ngModel)]="text" class="form-control" placeholder="Search" name="text">
<button class="btn btn-default" type="submit" (click)="clear()"><i class="glyphicon glyphicon-remove"></i></button>
<div class="input-group-btn">
<button class="btn btn-default" type="submit" (click)="search()"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
I honestly think that buttons are a pain in the butt and are outdated. I much rather use a simple div, a or in this case i tag.
Therefore this might not be completely what OP asked for but in my eyes it is a more elegant solution.
The secret to this solution is using the flex property to the wrapper, which makes it possible to automatically size its children within its space.
.field {
display: flex;
position: relative;
max-width: 285px;
min-width: 200px;
width: 100%;
flex-direction: row;
}
Please check out the snippet for a more specific example. This works in all modern browsers and from internet explorer 10.
var input = document.getElementById("search");
function clearInput() {
input.value = "";
}
function search () {
console.log("searching");
// Implement search function here...
}
.field {
display: flex;
position: relative;
max-width: 285px;
min-width: 200px;
width: 100%;
flex-direction: row;
}
.field > input[type=text] {
flex: 1;
padding: 0.6em 0.6em 0.6em 1.5em;
border: 1px solid #c4c4c4;
border-right: none;
display: block;
}
.field > div {
padding: 0.4em 0;
background-color: #fff;
border: 1px solid #c4c4c4;
border-left: none;
border-radius: 1px;
display: inline-block;
cursor: pointer;
}
.field > div > i {
padding: 0.2em 0.8em;
background-color: inherit;
color: #555555;
border: none;
border-left: 1px solid #c4c4c4;
margin-right: 1px;
}
.field > div:last-child > i {
border-left: none;
}
.field > div:hover > i {
color: #009BDB;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<div class="field">
<input type="text" id="search" placeholder="Search..." />
<div>
<i class="fa fa-times" onclick="clearInput()"></i>
</div>
<div>
<i class="fa fa-search" onclick="search()"></i>
</div>
</div>
You could play around with position: relative,
for example:
html:
<form class="navbar-form" role="search">
<div class="input-group add-on">
<input type="text" [(ngModel)]="text" class="form-control" placeholder="Search" name="text">
<button class="btn btn-default test" type="submit" (click)="clear()"><i class="glyphicon glyphicon-remove"></i></button>
<div class="input-group-btn">
<button class="btn btn-default" type="submit" (click)="search()"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
css:
.form-control {
position:relative;
}
.test {
position:relative;
right:20px;
}
example jsfiddle: https://jsfiddle.net/DTcHh/92025/

Center alignment not consistent

I'm trying to get the duration and current time text to stay centered vertically. Why is it that sometimes it will no center, and other times if I do a refresh, it works suddenly, even though I didn't change any code?
Here's a screenshot of it not working: Not Working
And here's another after doing a hard refresh, but not changing any of the code: Working
It's almost as if it's a hit or miss.
<div class="player-controls">
<div>
<button id="playpause-button">
<i class="fas fa-play fa-lg"></i>
</button>
</div>
<div class="time-container">
<span id="currenttime">00:00</span>
</div>
<div class="time-rail-container">
<div id="time-rail"></div>
</div>
<div class="time-container">
<span id="duration">00:00</span>
</div>
<div>
<button id="rewind-button">
<i class="fas fa-undo fa-lg"></i>
</button>
</div>
<div>
<button id="speed-button">
<i class="fas fa-tachometer-alt fa-lg"></i>
</button>
</div>
<div>
<button id="captions-button">
<i class="fas fa-closed-captioning fa-lg"></i>
</button>
</div>
<div>
<button id="volume-button"><i class="fas fa-volume-up fa-lg"></i></button>
</div>
</div>
Here's the CSS sheet:
.player-controls {
background: #2f2f2f;
display: block;
padding: 0;
margin: 0 auto;
text-align: left;
width: 840px;
height: 52px;
user-select: none;
}
.player-controls button {
background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
outline:none;
color: #fff;
}
.time-rail-container {
width: 443px;
}
.player-controls > div {
margin: 0 0 5px 0;
display: inline-block;
}
#playpause-button,
#rewind-button,
#speed-button,
#captions-button,
#volume-button {
padding: 0;
margin: 0 1px 0 0;
width: 56px;
height: 50px;
}
.time-container {
height: 50px;
line-height: 50px;
text-align: center;
}
#duration,
#currenttime {
vertical-align: middle;
}
It is because it isn't sure what to be referencing for the vertical-align since not all the elements you are trying to align are next to each other. Instead of aligning those two vertically, you need to set the vertical align on all of the elements inside of the player-controls.
.player-controls > * {
vertical-align: middle;
}
I echo user "Sticker"s advise... Try to add vertical-align:middle CSS to .player-controls button like below : here is a plunker https://plnkr.co/edit/tldchkIWflEDUFBQxZIw?p=preview
.player-controls button {
background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
outline:none;
color: #fff;
vertical-align:middle;
}