Bootstrap CSS Mobile Resize Issue - html

I am running into an issue using Bootstrap when re-sizing the page to a mobile size. The input form is shifting to inline and the glyphicon I am using is not staying in the same position once the window is resized. I have included 2 pictures below on how it looks before and after resizing the window.
HTML code for input section:
<div class="col-sm-4" id="end">
<div class="row">
<div class="col-sm-6" id="start">
<span class="top">Date and Time</span>
<div class="input-group">
<div class = "input-group-addon"><span id="icon" class="glyphicon glyphicon-time"></span></div>
<input type="text" class="col-xs-4" id="date">
<input type="text" class="col-xs-4" id="time">
</div>
<button type="button" class="btn btn-info btn-sm" id="submit" onclick="getData()">Search</button>
</div>
<div class="col-sm-6" id="start">
</div>
</div>
</div>
CSS for the date and time ID's:
#date {
max-width: 100px;
min-width: 100px;
font-size: 12px;
}
#time {
max-width: 100px;
min-width: 100px;
margin-bottom: 0px;
font-size: 12px;
}
Normal sized look
Mobile sized look

If you sizing your #date and #time both to min-width: 100px and max-width: 100px as well, your div's wont be bigger or smaller then 100px.
Maybe you should use three declarations like:
width: 150px, min-width: 100px and max-width: 200px;
Another way would be the percentage sizing or #media screen and (...)
w3schools has a really good docu to figured it out an learn how to handle with all the diffrent ways of sizing.

It's not the most beautiful solution, but you can try to force the "input" to be wide as it can be with class="col-lg-12".
Like this:
<div class="col-sm-4" id="end">
<div class="row">
<div class="col-sm-6" id="start">
<span class="top">Date and Time</span>
<div class="input-group">
<div class = "input-group-addon"><span id="icon" class="glyphicon glyphicon-time" ></span></div>
<input type="text" class="col-lg-12" id="date">
<input type="text" class="col-lg-12" id="time">
</div>
<button type="button" class="btn btn-info btn-sm" id="submit" onclick="getData()">Search</button>
</div>
<div class="col-sm-6" id="start">
</div>
</div>

Related

Bootstrap button padding makes it appear like the button is going past the container border

Why does the "Subscribe now!" button go outside the container in the picture below and how can I make it so that the right edge lines up with the rest of the page? (column 12 in the bootstrap grid)
I have tried box-sizing: border-box but it had no effect.
My HTML code:
.container-fluid {
padding: 0;
}
.carousel-inner .carousel-item h1 {
font-weight: bold;
font-size: 300%;
/*-webkit-text-stroke:1px black;*/
font-family: 'Open Sans', sans-serif;
/*text-align:right;*/
}
.carousel-inner .carousel-item img {
filter: brightness(50%);
}
#paddingrow {
padding: 25px;
}
#paddingrowLarge {
padding: 100px;
}
#accordionRightalign {
float: right;
}
#mycard {
float: right;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row" id="paddingrow"></div>
<div class="row">
<div class="col-sm-12">
<h1 style="text-align:center">SUBSCRIBE TO OUR NEWSLETTER</h1>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<form>
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="Enter your email">
</div>
<button class="btn btn-primary" style="box-sizing: border-box" type="submit">Subscribe now!</button>
</div>
</form>
</div>
</div>
</div>
</div>
Bootstrap rows have margin-right: -15px; margin-left: -15px; that's why the right edge doesn't lined up. Try to add mx-0 = margin-left:0 and margin-right: 0, a bootstrap class. In your nested row form.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row" id="paddingrow"></div>
<div class="row">
<div class="col-sm-12">
<h1 style="text-align:center">SUBSCRIBE TO OUR NEWSLETTER</h1>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<form>
<div class="row mx-0">
<div class="col pl-0 pr-3">
<input type="text" class="form-control" placeholder="Enter your email">
</div>
<button class="btn btn-primary" style="box-sizing: border-box" type="submit">Subscribe now!</button>
</div>
</form>
</div>
</div>
</div>
</div>
Make sure col in the container with margin and padding to zero.
Put your image into container with the width not greather than 100%.
I noticed my button wasn't in the column div, so I made two column div's, one size 10 and one size 2, put input in the first, put the button in the second, and it seems to work now.
Here is the fixed code:
<div class="container">
<div class="row" id="paddingrow"></div>
<div class="row">
<div class="col-sm-12">
<h1 style="text-align:center">SUBSCRIBE TO OUR NEWSLETTER</h1>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<form class="form">
<div class="row">
<div class="col-sm-10">
<input type="text" class="form-control" placeholder="Enter your email">
</div>
<div class="col-sm-2">
<button class="btn btn-primary w-100" type="submit">Subscribe now!</button>
</div>
</div>
</form>
</div>
</div>
</div>

Does BS4 offer a means to size `.input-group` down on various devices

I'm looking to size a BS4 input-group down as and when it is loaded on various devices. Kinda like how you can tell a col what it should be displaying on various screens. I.e.
<div class="col-12 col-md-6 col-lg-4"></div>
I want to do something similar on mobile devices, I.e. on a desktop
use .input-group-lg on a mobile use .input-group-sm etc.
Is this something BS4 can do? (I can't see any mention of it in the
docs?)
Here's a jsfiddle with an example, if it helps.
I just created two custom class for input-group resizing for small, medium and large screen.
1st for small+medium screen like .input-group-sm-md class.
2nd for small+medium+large screen like .input-group-sm-md-lg class.
I follow breakpoint of Bootstrap4.
Doc Link: https://getbootstrap.com/docs/4.4/layout/overview/#responsive-breakpoints
Note: check on Full page from snippet box and resize browser to check input-group resize reflection.
I hope below snippet will help you.
#media(min-width: 991px){
/*Class for small + medium &large screen*/
.input-group-sm-md-lg>.custom-select,
.input-group-sm-md-lg>.form-control:not(textarea) {
height: calc(1.5em + 1rem + 2px);
}
.input-group-sm-md-lg>.custom-select,
.input-group-sm-md-lg>.form-control,
.input-group-sm-md-lg>.input-group-append>.btn,
.input-group-sm-md-lg>.input-group-append>.input-group-text,
.input-group-sm-md-lg>.input-group-prepend>.btn,
.input-group-sm-md-lg>.input-group-prepend>.input-group-text {
padding: .5rem 1rem;
font-size: 1.25rem;
line-height: 1.5;
}
}
#media(max-width: 575px){
.input-group-sm-md-lg>.custom-select,
.input-group-sm-md-lg>.form-control:not(textarea),
.input-group-sm-md>.custom-select,
.input-group-sm-md>.form-control:not(textarea){
height: calc(1.5em + .5rem + 2px);
}
.input-group-sm-md-lg>.custom-select,
.input-group-sm-md-lg>.form-control,
.input-group-sm-md-lg>.input-group-append>.btn,
.input-group-sm-md-lg>.input-group-append>.input-group-text,
.input-group-sm-md-lg>.input-group-prepend>.btn,
.input-group-sm-md-lg>.input-group-prepend>.input-group-text,
/*Class small+medium screen*/
.input-group-sm-md>.custom-select,
.input-group-sm-md>.form-control,
.input-group-sm-md>.input-group-append>.btn,
.input-group-sm-md>.input-group-append>.input-group-text,
.input-group-sm-md>.input-group-prepend>.btn,
.input-group-sm-md>.input-group-prepend>.input-group-text{
padding: .25rem .5rem;
font-size: .875rem;
line-height: 1.5;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container my-3">
<div class="row">
<div class="col-sm-12">
<form action="https://stackoverflow.com/users/7052927/raeesh-alam?tab=profile">
<div class="input-group mb-3 input-group-sm-md">
<input class="form-control" type="text" placeholder="input-group-sm-md">
<span class="input-group-append">
<button type="submit" class="btn btn-primary">Search</button>
</span>
</div>
<div class="input-group mb-3 input-group-sm-md-lg">
<input class="form-control" type="text" placeholder="input-group-sm-md-lg">
<span class="input-group-append">
<button type="submit" class="btn btn-primary">Search</button>
</span>
</div>
</form>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<div class="form-group">
<label>Title</label>
<input type="text" class="form-control" required>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<div class="form-group">
<label>Price</label>
<input type="text" class="form-control">
</div>
</div>
</div>

assigning css property to parent, not to child

In my application, I am using bootstrap-tagsinput angular version (in smartadmin) which looks like this
code for bootstrap input tag:
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label>Type and enter to add an SMA</label>
<input smartTags class="form-control tagsinput" value="{{tagsValues}}" data-role="tagsinput">
</div>
</div>
</div>
I am using this in my dashboard inside widget as a widget toolbar in dropdown popover
dashboard.component.html
<div class="widget-toolbar">
<div class="btn-group dropdown dropdown-large" dropdown>
<a class="button-icon" title="SMA Filter" dropdownToggle aria-expanded="true">
<i class="fa fa-cog"></i>
</a>
<div class="dropdown-menu dropdown-menu-large filterDropwdownViewAlign" (click)="$event.stopPropagation()">
<div id="checkout-form" class="smart-form">
<header id="filterHeader">SMA</header>
<fieldset>
<form>
<div class="row form-group">
<section class="col col-xs-12">
<label class="form-control" style="border:0px;height:auto">
<input id="smartTagInput" smartTags class="form-control tagsinput" value="{{smaValues}}" data-role="tagsinput">
</label>
</section>
</div>
</form>
</fieldset>
</div>
</div>
</div>
</div>
I have applied css properties to the popover
.filterFormAlign {
margin-bottom: 0px !important;
margin-top: 0px !important;
padding-right: 0px !important;
}
.filterFormAlignToggle{
padding-left: 0px !important;
}
.filterDropwdownViewAlign {
margin: 35px 0 0;
top: 3px;
padding: 0px !important;
}
#media only screen and (min-width:768px) {
.filterDropwdownViewAlign {
min-width: 335px !important;
left: -296px !important;
}
}
#media only screen and (max-width: 479px) and (min-width: 320px) {
.filterDropwdownViewAlign {
min-width: 310px !important;
left: -255px !important;
}
}
That bootstrap input tags element is not looking in this popover as I showed in the image above.
Maybe it is coming because of that css properties that is inherited by this input field also. So is there any way that those css properties will not be inherited by the input tag or element inside the form
Seems like you have an overwrite of css definition which is making <input> element display block instead of floated / inline.
I don't know if this is the solution but looking at the differences between the 2 cases I would suggest to close the <label> tag before the <input> element and not after input element, something like:
<label class="form-control" style="border:0px;height:auto">
</label>
<input id="smartTagInput" smartTags class="form-control tagsinput" value="{{smaValues}}" data-role="tagsinput">
And the whole snippet:
<div class="widget-toolbar">
<div class="btn-group dropdown dropdown-large" dropdown>
<a class="button-icon" title="SMA Filter" dropdownToggle aria-expanded="true">
<i class="fa fa-cog"></i>
</a>
<div class="dropdown-menu dropdown-menu-large filterDropwdownViewAlign" (click)="$event.stopPropagation()">
<div id="checkout-form" class="smart-form">
<header id="filterHeader">SMA</header>
<fieldset>
<form>
<div class="row form-group">
<section class="col col-xs-12">
<label class="form-control" style="border:0px;height:auto">
</label>
<input id="smartTagInput" smartTags class="form-control tagsinput" value="{{smaValues}}" data-role="tagsinput">
</section>
</div>
</form>
</fieldset>
</div>
</div>
</div>
</div>

Bootstrap Responsive Search Engine Layout

I'm trying to have a responsive input and a logo ontop of it using bootstrap. I tried every thing within my knowledge to do it. Columns (gridsystem), resize, etc. No matter how I do it. It turns out buggy. i.e when I size the browser window down it starts getting out of order.
Resize the result window to see how everything is pulled out of porportion.
http://jsfiddle.net/Cbuyn/
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<img src="http://placehold.it/500x300" class="img-responsive" alt="Responsive image">
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="input-group">
<input type="text" class="form-control" placeholder="">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</div>
</div>
</div>
This is done with Bootstrap 3. I'm out of ideas..
If you want to center your image (assuming you add an id="main-img" to the image):
#main-img {
margin-left: auto;
margin-right: auto;
}
jsFiddle Demo (image centered)
If you want to make the image full width:
#main-img {
width: 100%;
}
jsFiddle Demo (image full width) (Updated as per comments)
I see from the comments that you have a solution. That said, the following works fine without adding the additional classes. It will be 100% at xs and sm sizes, then beginning at the md size, it will be 50% of the container. Remember, responsive isn't about people resizing their browser, it's about different device sizes. Most people (other than developers who build responsive websites and are trying to test them) don't resize their browsers when they are looking at a page. Also, if you're on a mobile type device, in most cases you can't resize your browser. So, if you want the 992px (md) and up viewports to see the input/image at only 50% of the container, your code was perfectly fine.
DEMO
HTML:
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<img src="http://placehold.it/500x300" class="img-responsive" alt="Responsive image" />
</div>
<div class="col-md-6 col-md-offset-3">
<div class="input-group">
<input type="text" class="form-control" placeholder="" />
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</div>
</div>
</div>
As #dan stated, if you want the image to be the same width as the input you can add:
img {
width: 100%;
}
or to center it and make it remain no larger than it's max-size:
img {
display: block;
margin: auto:
}

Aligning elements in html using bootstrap classes

I have the following code
html page(part of it)
<div class="container">
<div class="right-page col-md-9">
<div class="row">
<div class="category-item col-md-4">
<form action="/settings/category/2/" method="post" class="form-inline">
<div class="container">
<div class="row input-container">
<div class="form-group">
<div class="col-md-8">
<input class="form-control input-sm col-md-3" type="text" value="KONS ">
</div>
<div class="col-md-3">
<input class="form-control input-sm col-md-3 myColorPicker">
</div>
</div>
</div>
</div>
<div class="container">
<div class="row btn-container">
<button class="btn btn-default btn-sm edit-category">Cancel</button>
<button name="delete" class="btn btn-default btn-sm">Delete</button><input type="submit" name="submit" class="btn btn-default btn-sm" value="Save">
</div>
</div>
</form>
</div>
</div>
</div>
and the css (part of it)
.diagnosis-phrase,
.treatment-phrase,
.category-item{
padding-bottom: 1em;
padding-top: 0.5em;
border: 1px solid black;
margin-bottom: 0.5em;
}
.diagnosis-phrase input[type="text"],
.treatment-phrase input[type="text"],
.category-item input[type="text"]{
margin-bottom:0.5em;
}
.category-item p{
padding-left: 0.5em;
padding-bottom:0.3em;
border-radius:0.5em;
width:50%;
}
The bootply for it. The part of html is the right column of a two column webpage. As you can see inside the div with black border I have two input boxes(For some reason the second appears outside the div with borders but in my working code appears correctly. Maybe because of me providing part of page.). My problem is that the first one is not aligned with the Cancel button. How can I do that using bootstrap classes?
if you use the following styles
.form-group .col-md-8:first-child {padding-left:0;}
It should fix your problem
Or if you just change the col-md-8 class on your div to col-md-pull-8 it should also achieve the same thing