Im having problem while adapting desktop ui to mobile. When i set col-md values from desktop, components resize according to value of col-md but when i add col-sm attribute to these same component there arent any changes in mobile side.
I am using bootstrap 3 by the way
Images will explain better.
CODE
<div id='main' class="container" ng-controller="searchController">
<div class="row" id='tags'>
<div class="col-md-3 col-sm-2" style="display:inline-block">
<h4>Images</h4>
</div>
<div class="col-md-3 col-sm-2" style="display:inline-block">
<h4>Name</h4>
</div>
<div class="col-md-2 col-sm-2" style="display:inline-block">
<h4>Type</h4>
</div>
<div class="col-md-2 col-sm-2" style="display:inline-block">
<h4>Price</h4>
</div>
<div class="col-md-1 col-sm-1" style="display:inline-block">
<h4>Cart</h4>
</div>
<div class="col-md-1 col-sm-1" style="display:inline-block">
<h4>Wishlist</h4>
</div>
</div>
<hr>
<div ng-repeat="result in results" ng-controller="buttonController">
<div class="row">
<div id='image' class="col-md-3 col-sm-3">
<img ng-src="{{result.image}}" style="max-width: 100%;max-height: 100%;">
</div>
<div class="col-md-3 col-sm-1">
<a ng-href='/product/{{result.id}}'>
<h3>{{result.name}}</h3>
</a>
</div>
<div class="col-md-2 col-sm-2" style="display:inline-block">
<h5 style="margin-top:30px">{{result.category}}</h5>
</div>
<div class="col-md-2 col-sm-2">
<h5 style="margin-top:30px">{{result.price}} {{result.currency}}</h5>
</div>
<div class="col-md-1 col-sm-1" style="display:inline-block">
<button ng-click='addBasket(result.id)' type="button" class="btn btn-default btn-sm" style="margin-top:30px">
<span class="glyphicon glyphicon-shopping-cart"></span>
</button>
</div>
<div class="col-md-1 col-sm-1" style="display:inline-block">
<button ng-click='addWishlist(result.id)' type="button" class="btn btn-default btn-sm" style="margin-top:30px">
<span class="glyphicon glyphicon-star"></span>
</button>
</div>
</div>
<div class="col-md-6 alert alert-info ng-cloak" style="float: none; margin: 0 auto;" ng-show="basketAlert">
<strong>Confirm!</strong> This product has been added to your basket.
</div>
<div class="col-md-6 alert alert-info ng-cloak" style="float: none; margin: 0 auto;" ng-show="wishlistAlert">
<strong>Confirm!</strong> This product has been added to your wishlist.
</div>
<div class="col-md-6 alert alert-warning ng-cloak" style="float: none; margin: 0 auto;" ng-show="alreadyInBasketAlert">
<strong>Hey!</strong> This product is already in your basket.
</div>
<div class="col-md-6 alert alert-warning ng-cloak" style="float: none; margin: 0 auto;" ng-show="alreadyInWishlistAlert">
<strong>Hey!</strong> This product is already in your wishlist.
</div>
<hr>
</div>
Im not so good at html pages. Thanks.
From what I'm seeing in the Bootstrap 3 docs, you'll want to use col-xs since your targeting mobile devices ( width < 768px ). The HTML would look like this. I replaced col-sm with col-xs. :
<div id='main' class="container" ng-controller="searchController">
<div class="row" id='tags'>
<div class="col-md-3 col-xs-2" style="display:inline-block">
<h4>Images</h4>
</div>
<div class="col-md-3 col-xs-2" style="display:inline-block">
<h4>Name</h4>
</div>
<div class="col-md-2 col-xs-2" style="display:inline-block">
<h4>Type</h4>
</div>
<div class="col-md-2 col-xs-2" style="display:inline-block">
<h4>Price</h4>
</div>
<div class="col-md-1 col-xs-1" style="display:inline-block">
<h4>Cart</h4>
</div>
<div class="col-md-1 col-xs-1" style="display:inline-block">
<h4>Wishlist</h4>
</div>
</div>
<hr>
<div ng-repeat="result in results" ng-controller="buttonController">
<div class="row">
<div id='image' class="col-md-3 col-xs-3">
<img ng-src="{{result.image}}" style="max-width: 100%;max-height: 100%;">
</div>
<div class="col-md-3 col-xs-1">
<a ng-href='/product/{{result.id}}'>
<h3>{{result.name}}</h3>
</a>
</div>
<div class="col-md-2 col-sm-2" style="display:inline-block">
<h5 style="margin-top:30px">{{result.category}}</h5>
</div>
<div class="col-md-2 col-sm-2">
<h5 style="margin-top:30px">{{result.price}} {{result.currency}}</h5>
</div>
<div class="col-md-1 col-xs-1" style="display:inline-block">
<button ng-click='addBasket(result.id)' type="button" class="btn btn-default btn-sm" style="margin-top:30px">
<span class="glyphicon glyphicon-shopping-cart"></span>
</button>
</div>
<div class="col-md-1 col-xs-1" style="display:inline-block">
<button ng-click='addWishlist(result.id)' type="button" class="btn btn-default btn-sm" style="margin-top:30px">
<span class="glyphicon glyphicon-star"></span>
</button>
</div>
</div>
<div class="col-md-6 alert alert-info ng-cloak" style="float: none; margin: 0 auto;" ng-show="basketAlert">
<strong>Confirm!</strong> This product has been added to your basket.
</div>
<div class="col-md-6 alert alert-info ng-cloak" style="float: none; margin: 0 auto;" ng-show="wishlistAlert">
<strong>Confirm!</strong> This product has been added to your wishlist.
</div>
<div class="col-md-6 alert alert-warning ng-cloak" style="float: none; margin: 0 auto;" ng-show="alreadyInBasketAlert">
<strong>Hey!</strong> This product is already in your basket.
</div>
<div class="col-md-6 alert alert-warning ng-cloak" style="float: none; margin: 0 auto;" ng-show="alreadyInWishlistAlert">
<strong>Hey!</strong> This product is already in your wishlist.
</div>
<hr>
</div>
Related
I have a BootStrap 5 row, the columns of which will always remain the same, even if the content inside of them overflows the column. How do I make it so that when content is larger than the column, the column expands in size?
As you can see, the columns (purple) let the cards inside of them overflow, therefore causing them to collide with other cards. What I want is for the columns to expand when the content inside of them is bound to overflow.
HTML for rows and columns:
<div class="row">
<div class="col">
<h1 class="header">User</h1>
<div class="card card-large border-0 me-1">
<div class="card-body shadow">
<div class="row row-cols-2">
<div class="col" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-user-pen" style="font-size: 50px;"></i>
</div>
<div class="right-column">
<a class="header row pt-2">Username: </a>
<a class="header row pt-2">Plan: </a>
<a class="header row pt-2">Discord: </a>
<a class="header row pt-2">Date of registration: </a>
<a class="header row pt-2">Used searches: /</a>
</div>
</div>
<div class="mt-2">
<a class="btn shadow text-white me-1" style="background-color: #7289da">Link Discord</a>
<a class="btn btn-secondary shadow text-white me-1">Change password</a>
<a class="btn btn-danger shadow text-white" data-bs-toggle="modal" data-bs-target="#logout">Log out</a>
<div class="modal fade" id="logout" data-bs-backdrop="logout" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" style=" width: 25rem">
<div class="modal-content text-white">
<div class="modal-body" style="background-color: #0e0e0e">
<div class="container">
<div class="row justify-content-center">
<div class="col-1" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-triangle-exclamation" style="font-size: 50px;"></i>
</div>
<div class="col-8 mt-4">
Are you sure you wish to log out?
</div>
</div>
</div>
</div>
<div class="modal-footer border-0 justify-content-center" style="background-color: #0e0e0e">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button data-bs-dismiss="modal" type="button" class="btn btn-danger" #click="deleteCookie()">Log out</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col">
<h1 class="header">Plan</h1>
<div class="card card-large border-0 me-1">
<div class="card-body shadow">
<div class="row row-cols-2">
<div class="col" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-tag" style="font-size: 50px;"></i>
</div>
<div class="right-column">
<a class="header row pt-2">Plan: </a>
<a class="header row pt-2">Date of Purchase: </a>
<a class="header row pt-2">Date of Expiration: </a>
</div>
</div>
<div class="mt-2">
<a class="btn btn-primary shadow text-white me-1" #click="">Upgrade</a>
<a class="btn btn-danger shadow text-white">Cancel</a>
</div>
</div>
</div>
</div>
<div class="col">
<h1 class="header">API</h1>
<div class="card card-large border-0 me-3">
<div class="card-body shadow">
<div class="row row-cols-2">
<div class="col" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
<i class="fa-solid fa-code" style="font-size: 50px;"></i>
</div>
<div class="right-column">
<a class="header row pt-2">Used searches: /</a>
</div>
</div>
<div class="mt-2">
<a class="btn btn-secondary shadow text-white me-1 disabled">API docs</a>
<a class="btn btn-secondary shadow text-white me-1" onclick="">Copy API key</a>
<a class="btn btn-secondary shadow text-white">Regenerate API key</a>
</div>
</div>
</div>
</div>
</div>
Add col-lg-4 in column row like this
<div class="row">
<div class="col-lg-4">
//content
</div>
<div class="col-lg-4">
//content
</div>
<div class="col-lg-4">
//content
</div>
</div>
For more information, please visit this link : https://getbootstrap.com/docs/5.2/layout/columns/#how-they-work
I am trying to make a responsive grid but I was very unsuccessful.
I am new to bootstrap and I am not very good in Front-end.
I tried some codes but this one is the closest one to my needs.
<div><p>MY TEXT HERE -------------------------</p></div>
<div>
<div id="containerTest" class="container-fluid" style="margin-left: 0px;">
<div class="row">
<div class="col-sm-3" style="background-color:red;" >AAAA</div>
<div class="col-sm-6" style="background-color:lavenderblush;">BBBBB</div>
<div class="col-sm-3" style="background-color:lavender;">
<button class="button button2">OK</button></div>
</div>
</div>
With this Bootstrap 4 code, the layout looks like your drawing.
<div class="container">
<div class="row">
<div class="col-12">
<p>My text here</p>
</div>
</div>
<div class="row">
<div class="col-3 col-md-2 pt-2 pr-0">
<label>Input label</label>
</div>
<div class="col-6 col-md-2 pr-0">
<input type="text" class="form-control w-100">
</div>
<div class="col-3 d-md-none">
<button type="button" class="btn btn-success">Save</button>
</div>
<div class="col-12 col-md-3">
<input type="text" class="form-control w-100">
</div>
<div class="col-12 col-md-3 d-none d-md-flex pl-0">
<button type="button" class="btn btn-success">Save</button>
</div>
</div>
<div class="row">
<div class="col-12">
<p>Other elements here</p>
</div>
</div>
</div>
That should do it.
<div class="container">
<div class="row">
<div class="col-sm-12">My text here ------------------</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-4">Input Label</div>
<div class="col-md-3 col-sm-4">Input</div>
<div class="col-md-3 hidden-sm">Input</div>
<div class="col-md-3">Save button</div>
</div>
<div class="row visible-sm">
<div class="col-sm-12">
<div class="col-md-3">Input</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">Text Area here</div>
</div>
</div>
I have used bootstrap for my website, simply put there are two column enclosed in col-md-12, they are col-md-6,
They should not be collapsing because enough space is given, why is this happening?
<div class="container-fluid" style="margin: 0">
<div class="row">
<div class="col-md-12">
<div class="col-md-6 ">
<div class="col-sm-12">
<img class="centering newReq" src="add-512.png" height="132" width="142">
</div>
<div class="col-sm-12">
<button type="button" class="btn btn-warning centering btnAdjust">New Request</button>
</div>
</div>
<div class="col-md-6 ">
<div class="col-sm-12">
<img class="centering newReq" src="contact.png" height="132" width="142">
</div>
<div class="col-sm-12">
<button type="button" class="btn btn-warning centering btnAdjust">My request</button>
</div>
</div>
</div>
</div>
</div>
Just remove the col-md-12 because each row contains each column. Optionally try to use
img-responsive class instead of setting width and height for image.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container-fluid" style="margin: 0">
<div class="row">
<div class="col-md-6 ">
<div class="col-sm-12">
<img class="centering newReq img-responsive" src="https://via.placeholder.com/150" height="132" width="142">
</div>
<div class="col-sm-12">
<button type="button" class="btn btn-warning centering btnAdjust">New Request</button>
</div>
</div>
<div class="col-md-6 ">
<div class="col-sm-12">
<img class="centering newReq img-responsive" src="https://via.placeholder.com/150" height="132" width="142">
</div>
<div class="col-sm-12">
<button type="button" class="btn btn-warning centering btnAdjust">My request</button>
</div>
</div>
</div>
</div>
I cant find the way to put the button on the same line as the form and text in responsive desing for mobile.
<div class="col-xs-12 col-md-6 nopadding">
<div class="row col-xs-8 col-md-8 pts-vcenter">
<div class="col-xs-4 col-sm-5 col-md-5">
<span class="bold">{l s='Voucher' mod='onepagecheckoutps'}</span>
</div>
<div class="col-xs-4 col-sm-7 col-md-7 nopadding-xs">
<input type="text" class="discount_name form-control" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name|escape:'htmlall':'UTF-8'}{/if}" />
</div>
</div>
<div class="col-xs-4">
<span type="button" id="submitAddDiscount" name="submitAddDiscount" class="btn btn-default btn-small">
{l s='Add' mod='onepagecheckoutps'}
</span>
</div>
</div>
Try to use col-xs-12 like this:
<div class="col-xs-12">
<span type="button" id="submitAddDiscount" name="submitAddDiscount" class="btn btn-default btn-small">
{l s='Add' mod='onepagecheckoutps'}
</span>
</div>
And don't forget to use the row class :)
I am using uib-accordions to display some data. I have defined accordion header as a row and split it into various columns to display various data elements.
Accordion View in Small and larger screens |
Accodion View in XS scren
Column distribution:
Store ID (col-xs-12 col-sm-5)
Controls (col-xs-12 col-sm-5): [SFS (Col-xs-4), BOPIS(col-xs-4), BOSTS(col-xs-4)]
Arrow Icon (col-xs-2 col-sm-1)
Now in small view all the glyphicon icon elements split into next row. I am trying to get display these icons in the same row as their labels, and there seems to be empty space available.
Secondly, how do we align phone, address and various toggle switch properly into a grid ? I have tried various options to center the toggle switches and save button, but it always breaks the view.
Here is the code:
<div class="container">
<div class="col-xs-12">
<hr>
<h4> Search: </h4>
<hr>
</div>
<div class="mycontainer row row-content" ng-controller="MainController" style="padding-top:100px" ng-cloak>
<uib-accordion close-others="true" ng-controller="ItemController" >
<div uib-accordion-group is-open="isopen" ng-repeat="item in items">
<uib-accordion-heading>
<div class="row" style="padding-top:3px">
<div class="col-xs-12 col-sm-5 ">
Store ID #: {{item.storeid}} | {{item.desc}}
</div>
<div class="col-xs-10 col-sm-6">
<div class="row">
**<div class="col-xs-4">SFS <span ng-if="item.SFS" class="glyphicon glyphicon-ok-circle"></span><span ng-if="!item.SFS" class="glyphicon glyphicon-remove-circle"></span> </div>
<div class="col-xs-4">BOPIS <span ng-if="item.BOPIS" class="glyphicon glyphicon-ok-circle"></span><span ng-if="!item.BOPIS" class="glyphicon glyphicon-remove-circle"></span></div>
<div class="col-xs-4">BOSTS <span ng-if="item.BOSTS" class="glyphicon glyphicon-ok-circle"></span><span ng-if="!item.BOSTS" class="glyphicon glyphicon-remove-circle"></span></div>
</div>**
</div>
<div class="col-xs-2 col-sm-1 ">
<i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': isopen, 'glyphicon-chevron-right': !isopen}"></i>
</div>
</div>
</uib-accordion-heading>
<div class="row">
<div class="col-xs-12 col-sm-4">
<a ng-href="tel:{{item.phone}}">
<span class="glyphicon glyphicon-earphone "></span> Phone: {{item.phone}}<br>
</a>
<a href="#">
<span class="glyphicon glyphicon-map-marker"></span> Address: {{item.address}}<br>
</a>
</div>
<div class="col-xs-12 col-sm-8 ">
<div class="col-xs-12 col-sm-4">
SFS:
<toggle ng-model="item.SFS" aria-label="SFS Switch"></toggle>
</div>
<div class="col-xs-12 col-sm-4">
BOPIS:
<toggle ng-model="item.BOPIS" aria-label="SFS Switch"></toggle>
</div>
<div class="col-xs-12 col-sm-4">
BOSTS:
<toggle ng-model="item.BOSTS" aria-label="SFS Switch"></toggle>
</div>
</div>
<div class="col-xs-12">
<button class="btn btn-primary .btn-sm">Save</button>
</div>
</div>
</div>
</uib-accordion>
</div>
</div>
Bootply: https://www.bootply.com/rFa5pgA0rv
CSS:
.nowrap{
white-space: nowrap;
}
#media screen and (max-width:768px) {
.pull-right-xs{float:right;}
}
Kind of HTML
<div class="container">
<div class="col-xs-12">
<hr>
<h4> Search: </h4>
<hr>
</div>
<div class="mycontainer row row-content" ng-controller="MainController" style="padding-top:100px" ng-cloak>
<uib-accordion close-others="true" ng-controller="ItemController" >
<div uib-accordion-group is-open="isopen" ng-repeat="item in items">
<uib-accordion-heading>
<div class="row" style="padding-top:3px">
<div class="col-xs-12 col-sm-5 ">
Store ID #: {{item.storeid}} | {{item.desc}}
</div>
<div class="col-xs-10 col-sm-6">
<div class="row">
**<div class="col-xs-4 nowrap">SFS <span ng-if="item.SFS" class="glyphicon glyphicon-ok-circle"></span><span ng-if="!item.SFS" class="glyphicon glyphicon-remove-circle"></span> </div>
<div class="col-xs-4 nowrap">BOPIS <span ng-if="item.BOPIS" class="glyphicon glyphicon-ok-circle"></span><span ng-if="!item.BOPIS" class="glyphicon glyphicon-remove-circle"></span></div>
<div class="col-xs-4 nowrap">BOSTS <span ng-if="item.BOSTS" class="glyphicon glyphicon-ok-circle"></span><span ng-if="!item.BOSTS" class="glyphicon glyphicon-remove-circle"></span></div>
</div>**
</div>
<div class="col-xs-2 col-sm-1 ">
<i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': isopen, 'glyphicon-chevron-right': !isopen}"></i>
</div>
</div>
</uib-accordion-heading>
<div class="row">
<div class="col-xs-12 col-sm-4">
<a ng-href="tel:{{item.phone}}">
<span class="glyphicon glyphicon-earphone "></span> Phone: {{item.phone}}<br>
</a>
<a href="#">
<span class="glyphicon glyphicon-map-marker"></span> Address: {{item.address}}<br>
</a>
</div>
<div class="col-xs-6 col-sm-8 ">
<div class="col-xs-12 col-sm-4">
SFS:
<toggle class="pull-right-xs" ng-model="item.SFS" aria-label="SFS Switch">toggle</toggle>
</div>
<div class="col-xs-12 col-sm-4">
BOPIS:
<toggle class="pull-right-xs" ng-model="item.BOPIS" aria-label="SFS Switch">toggle</toggle>
</div>
<div class="col-xs-12 col-sm-4">
BOSTS:
<toggle class="pull-right-xs" ng-model="item.BOSTS" aria-label="SFS Switch">toggle</toggle>
</div>
</div>
<div class="col-xs-12">
<button class="btn btn-primary .btn-sm">Save</button>
</div>
</div>
</div>
</uib-accordion>
</div>
</div>