How responsive input form in bootstrap - css

I get one problem with some css and bootstrap, i still not find solution
the problem is div form content not reponsive by its parent div and always move div content outside of parent div and not adjust by parent div size when i change screen size for multiple devices.
I have one dive classs wrapper and inside it there are one nav and one div content
<div class="wrapper">
<!-- Sidebar -->
<nav id="sidebar" >
</nav>
<div id="content">
<div class="row main">
<div class="col-lg-3">
</div>
<div class="col-lg-6 col-md-8 col-sm-12 col-xs-12 trade">
</div>
<div class="col-lg-3">
</div>
</div>
</div>
in div content , there are one row , inside row , there are 3 div columns , in middle column , there one row that has problem .
<div class="col-lg-6 col-md-8 col-sm-12 col-xs-12 trade">
<div class="tab_container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<form>
<div class="input-wrapper">
<div class="prefix">Price</div>
<input type="number" id="price" placeholder="Price">
<div type="text" class="css">Last</div>
<div class="suffix">USD</div>
</div>
</form>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<form>
<div class="input-wrapper">
<div class="prefix">Price</div>
<input type="number" id="price" placeholder="Price">
<div type="text" class="css">Last</div>
<div class="suffix">USD</div>
</div>
</form>
</div>
</div>
</div>
</div>
its css is
.wrapper {
display: flex;
width: 100%;
align-items: stretch;
}
#content{
width: 100%;
padding: 14px;
min-height: 100vh;
}
.tab_container{
padding:1px;
display:none;
}
form{
background-color: #ffffff;
border-radius: 10px;
}
.input-wrapper{
display: flex;
background-color: #222020;
border: 1px solid #7b7b93;
margin: 10px 0;
border-radius: 5px;
}
.prefix,
.suffix{
color: #7b7b93;
}
.prefix{
padding: 3px;
width:50px;
}
.suffix{
width:60px;
padding:2px 0px 0px 8px;
}
.css,.cdd{
padding:2px ;
color:#f5f5f8;
}
input{
background-color: transparent;
text-align: right;
color: #f5f5f8;
width:110px;
}
here is desktop screen size
here is small laptop size
div content not responsive and move outside
here is tablet view
here is mobile view
it not adjust by parent div size ...
I first think it may be bootstrap grid problem , i changed for various device columns , not ok .
may be due to form responsive problem , this form not change when screen size change .
my experience too low in frontend , please help me , How can i fix that

Try to switch up the sizing of your bootstrap columns and div classes.
For example, you have applied a 60px width to "suffix". On a smaller device that displays less pixels on the screen, it could struggle to show 60px of "suffix" content whilst also trying to display the rest of the page.
Suffix should really be set to % rather than px. You would apply px to the column itself then define how much % suffix should take up inside the column.
I'm not an expert with grids and bootstrap and run in to similar issues, but I recommend you try out Webflow - it's free to use and allows you to generate these grids yourself, responsive to all screen sizes. You can then take the code from Webflow and apply it within your own website you're having problems with.

Related

Bootstrap 4 How to Overlap Two Divs that Stack Responsively

I'm a backend guy and trying to figure out a few details for a project we have that's using Bootstrap 4.
Simply put, we want to create the layout that's executed here:
https://codepen.io/mediumandmessage/pen/xVeXop
(this example and the code below is from the original Bootstrap 3 example I found, not Bootstrap 4)
HTML:
.somesection {margin-top:50px!important;}
body {
font-size:17px;
font-family:Helvetica Neue;
}
img {max-width:100%;}
.overlay-text {
font-size:3.5vw;
float:right;
width:65%; /*important*/
bottom:21vw; /*important*/
padding: 25px;
background:#f7f7f7;
}
<div class="container somesection">
<div class="row col-xs-6">
<img src="https://images.unsplash.com/photo-1459664018906-085c36f472af?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1087&h=725&q=80">
</div>
<div class="col-xs-3 col-sm-offset-4 overlay-text">
This is some text that should partially overlay.
</div>
</div>
However, that example uses Bootstrap 3 and breaks in Bootstrap 4 (the text displays horizontally below the image) and also does not stack the divs responsively.
I've tried screwing around with absolute and relative positioning, etc. it became a lot of code to execute cleanly and make responsive and I was hoping someone out there may have some insight into implementing in pure Bootstrap4...
If anyone out there can share any expertise here, I'd greatly appreciate it!
You could add a transform to your overlay column (you may need to cancel this with a media query for your smaller screens).
Please note in the html below, I have fixed your code to work with boostrap 4 - columns have to be inside a row (they cannot be on a row) and I don't think there is a -xs class any more
.overlay-text {
/* these two are needed - the align self makes the column not stretch the whole height of the image column and the translate moves the column over the image */
align-self: flex-start;
transform: translateX(-20%);
/* the following are for example only */
background-color: #ffffff;
padding:20px;
}
<div class="container somesection">
<div class="row">
<div class="col col-sm-6">
<img src="https://images.unsplash.com/photo-1459664018906-085c36f472af?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1087&h=725&q=80" class="w-100">
</div>
<div class="col col-sm-3 col-sm-offset-4 overlay-text">
This is some text that should partially overlay.
</div>
</div>
</div>
Example bootply
Just add position:relative; to the .overlay-text
You can also adjust the value of bottom
.somesection {margin-top:50px!important;}
body {
font-size:17px;
font-family:Helvetica Neue;
}
img {max-width:100%;}
.overlay-text {
font-size:3.5vw;
float:right;
width:65%; /*important*/
bottom:21vw; /*important*/
padding: 25px;
background:#f7f7f7;
position:relative;
}
<div class="container somesection">
<div class="row col-xs-6">
<img src="https://images.unsplash.com/photo-1459664018906-085c36f472af?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1087&h=725&q=80">
</div>
<div class="col-xs-3 col-sm-offset-4 overlay-text">
This is some text that should partially overlay.
</div>
</div>

Reduce the height of column in small device (col-xs)

I am using following div to display Image, Description, Content. The height of the div is fixed 416px. This is working fine. Till now in mobile device we were showing single column. As per our current requirement we would like to display three rows in mobile device.
I modified
<div class="categoryProduct col-lg-3 col-md-4 col-sm-5 col-xs-12" >
to
<div class="categoryProduct col-lg-3 col-md-4 col-sm-5 col-xs-6" > or
<div class="categoryProduct col-lg-3 col-md-4 col-sm-5 col-xs-4" >
I noticed that since the height was fixed to 416 there is lot of gap between rows when we shrink the size. How can i reset the size as per device.
Following is the div tag code
<div class="categoryProduct col-lg-3 col-md-4 col-sm-5 col-xs-12" >
<div class="slides">
<img src="src" width="222" height="296" />
</div>
<div class="productText" style="border-top: 1px solid #f0f0f0;">
<p class="product-list-designer">Designer</p>
<p class="product-list-title">Title</p>
<p class="product-list-price">Text</p>
</div>
</div>
Following is the css code
div.categoryProduct {
background-color: transparent;
float: left;
height: 418px;
padding: 5px 15px 20px;
}
div.categoryProduct div.productImage {
padding-bottom: 3px;
border-bottom: 1px solid #f0f0f0;
}
div.categoryProduct div.productImage a {
display: block;
padding-bottom: 10px;
border-bottom: 1px solid #f0f0f0;
}
I tried adding custom height nothing worked. If i try to remove height setting, the column alignment is lost and results page looks very untidy. I tried adding min-height for the div column.
I am lost with col-xs part rest all rendering is happening ok.

Bootstrap background width padding

I'm using Boostrap 3 and have a problem with backgrounds on elements that appear too wide. The container is in desktop mode 1170px and has 15px padding left and right which makes the content appear with 1140px width.
When I'm adding an element with a different background color (let's say body + .container both has same background), then the element will appear as 1170px wide due to the background showing in the padding area as well.
I could add CSS for each element with deviating background in each screen width (media queries) to solve the problem. But I hope there is a better way to achieve this since I can't be the only person with this problem. Does anyone know some Boostrap class / function to solve this issue, or know some best practise for this?
Try wrapping the rows and/or inner content, you can see how I have done it here; http://jsfiddle.net/w7wowg94/
HTML
<div id="master-wrap">
<div class="container">
<div class="wrap-class-one">
<div class="row">
<div class="col-md-6">Content 1</div>
<div class="col-md-6">Contnent 2</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-4">
<div class="inner-wrap">Content 1</div>
</div>
<div class="col-md-4">
<div class="inner-wrap">Contnent 2</div>
</div>
<div class="col-md-4">
<div class="inner-wrap">Contnent 2</div>
</div>
</div>
</div>
</div>
CSS
#master-wrap {
margin: 0 auto;
background-color: #eee;
padding: 15px;
}
.wrap-class-one {
background-color: #ccc;
padding: 15px;
}
.inner-wrap {
padding: 15px;
background-color: #ccc;
}

Creating a fixed footer with Bootstrap

I am building an app that uses Bootstrap. I want this app to have a footer. The footer needs to "stick" to the bottom. In other words, if the content is larger than the height of the screen, the footer should still be visible, the content goes under it. If the content takes less than the height of the screen, I still need the footer to stick tothe bottom. I tried using the sticky footer. However, that doesn't work. Currently, I am trying the following:
Here's My Plunker
My HTML looks like this:
<div class="footer">
<div class="container text-center">
<button class="btn btn-warning"><span class="glyphicon glyphicon-filter"></span></button>
<button class="btn btn-warning"><span class="glyphicon glyphicon-th"></span></button>
</div>
</div>
How do I build a footer that permanently sticks to the bottom? I'm basically trying to build an "action bar" that is visible only when the site runs on a phone.
Thank you for your help.
use the following code
.footer {
background-color: #f5f5f5;
bottom: 0;
height: 60px;
position: fixed;
width: 100%;
}
you should change the footer position :
.footer {
background-color: #f5f5f5;
bottom: 0;
height: 60px;
position: fixed; /*change it*/
width: 100%;
}
Bootstrap comes with its nav elements ready to roll as a footer.
Simply create your element and add these classed navbar navbar-default navbar-fixed-bottom.
<footer>
<div class="navbar navbar-default navbar-fixed-bottom" id="footer">
<div class="container">
<p>this is your footer that sticks to the bottom</p>
</div>
</div>
</footer>
You can then expand on this by splitting the containing div into blocks with something like
<div class="row">
<div class="row">
<div class="col-xs-8 col-sm-6">
Level 2: .col-xs-8 .col-sm-6
</div>
<div class="col-xs-4 col-sm-6">
Level 2: .col-xs-4 .col-sm-6
</div>
</div>
</div>
the above would go inside the container div
as shown here http://jsfiddle.net/showcaseimagery/5y14pqgv/

Can't center a zurb foundation callout

This is probably boneheadedly easy, but I've tried a lot of different approaches and cannot get this bloody callout to center.
<div class="row">
<div class="large-12 small-12 center columns">
<div class="radius panel large-4 small-4 columns">
<div class="row"><input id="loginUserInput" name="loginUserInput" type="text" value="Username" /></div>
<div class="row"><input id="loginPasswordInput" name="loginPasswordInput" type="password" value="Password" /></div>
</div>
</div>
</div>
CSS:
.center {
margin: auto;
text-align: center;
}
Here's a jsfiddle:
http://jsfiddle.net/Sgwtd/
If you want to center that callout the foundation way, since you are already using it, then large-centered is your friend
<div class="radius panel large-4 small-4 columns large-centered">
If you want it centered in both desktop and mobile views then you can add small-centered
<div class="radius panel large-4 small-4 columns small-centered large-centered">
Add
float:none;
margin: auto;
to the callout's element <div class="radius panel large-4 small-4 columns">
There is a foundation media query that is floating it left. You might even wan to add an ID to that div and add the above styles to that instead, to prevent overwriting any potential occurrences of that which are supposed to be floated.
Your class .center can align only text, but as i see, in your div you have two another divs with row classes and input-fields inside.
So, if you want to align your input-fields centered - you need to change your
.center {
text-align: center;
}
to
.center {
margin-left: auto;
margin-right: auto;
}
Hope i understand you correctly.
Add this to your stylesheet:
.center .panel {
margin: 0 auto;
float: none;
}
You have to disable the float that is applied to the .columns class in order for margin: 0 auto; to work as expected.

Resources