put component on side of search field - html

I am developing a web application and would like my EntreCadastre-se|Carrinho menu to be next to the text field, but it is getting underneath
<div class="row">
<div class="col-6 col-md-4 col-xs-4">
<img src="imagens/eccomerce.JPG" alt="principal" id="imagem_principal">
</div>
<div class="col-6 col-md-4">
<div class="busca"><input type="text" id="campo_busca" placeholder="O que vocĂȘ procura?"><button type="submit" onclick="" class="buscar_produto "><i class="fa fa-search" action="" ></i></button> </div>
</div>
<div class="col-6 col-md-4">
<ul class="menu_2">
<div class="btn-group" role="group">
<div class="btn-group" role="group">
Entre/Cadastre-se <span class="caret"></span>
</div>
<button type="button" class="carrinho btn btn-default">Carrinho <i class="fa fa-shopping-cart"></i> ( )</button>
</div>
</ul>
</div>
</div>

What you are doing wrong here is your math. Like #efkin said you have only 12 columns. But you have defined three divs with col-6. That means 3*6 = 18.
When you want 3 columns with equal size on one row you have to use col-4 for each, because 3*4 = 12.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-4 col-md-4 col-xs-4">
<img src="imagens/eccomerce.JPG" alt="principal" id="imagem_principal" >
</div>
<div class="col-4 col-md-4">
<div class="busca"><input type="text" id="campo_busca" placeholder="O que vocĂȘ procura?"><button type="submit" onclick="" class="buscar_produto "><i class="fa fa-search" action="" ></i></button> </div>
</div>
<div class="col-4 col-md-4">
<ul class="menu_2">
<div class="btn-group" role="group">
<div class="btn-group" role="group">
Entre/Cadastre-se <span class="caret"></span>
</div>
<button type="button" class="carrinho btn btn-default">Carrinho <i class="fa fa-shopping-cart"></i> ( )</button>
</div>
</ul>
</div>
</div>

Related

How to make bootstrap columns automatically resize when element overflows them

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

Bootsrap 4 Grid or Flex

I have a form that looks like the following:
<div class="row">
<div class="col">
<textarea name="comment" class='form-control' placeholder='Type new comment here..'></textarea>
</div>
<div class="col">
<div class="row">
<div class="col">
<button class="btn btn-secondary btn-sm" type='button'><span class="fa fa-times mr5"></span>Cancel</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn btn-primary btn-sm mt5" name='new_comment' type='submit'><span class="fa fa-plus mr5"></span>Save</button>
</div>
</div>
</div>
</div>
I'm using Bootstrap 4. The thing is, I want this form to be the max width of its container - to have the textarea stretch and the buttons be a static width. If I use the above, I get a big empty gap because the smallest col (col-1) is to wide for the buttons. How can I have it fill the width of the screen with the button columns remaining a fixed width?
I have a feeling its using flex and d-flex but I cant manage to get it work.
add flex-grow-0 to buttons column:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" >
<div class="container-fluid">
<div class="row">
<div class="col">
<textarea name="comment" class='form-control' placeholder='Type new comment here..'></textarea>
</div>
<div class="col flex-grow-0">
<div class="row">
<div class="col">
<button class="btn btn-secondary btn-sm" type='button'><span class="fa fa-times mr5"></span>Cancel</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn btn-primary btn-sm mt5" name='new_comment' type='submit'><span class="fa fa-plus mr5"></span>Save</button>
</div>
</div>
</div>
</div>
</div>
You can remove .col and use d-flex and flex-grow-1.
Then, you can also add a margin-left using ml-3 to the buttons.
<div class="row mw-100">
<div class="d-flex flex-grow-1">
<textarea name="comment" class='form-control' placeholder='Type new comment here..'></textarea>
</div>
<div class="ml-3">
<div class="row">
<div class="col">
<button class="btn btn-secondary btn-sm" type='button'><span class="fa fa-times mr5"></span>Cancel</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn btn-primary btn-sm mt5" name='new_comment' type='submit'><span class="fa fa-plus mr5"></span>Save</button>
</div>
</div>
</div>
</div>
For the buttons container, you can set the width you want.

Why my button isnt in the same row as the form and the string?

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 :)

Bootstrap list of thumbnails leaves empty columns

I am trying to make a list of images with titles using Bootstrap 3.3.7, like an image gallery and I am getting this weird behaviour
I am using an unordered list-group and for every image a list-group-item:
<section>
<div class="content container">
<div class="control row">
<div class="col-md-12">
<button class="btn btn-success btn-lg" data-toggle="modal" data-target="#myModal">Upload</button>
</div>
</div>
<ul class="list-group row">
{{#each pictures}}
<li class="list-group-item col-md-3 col-xs-6 col-sm-6">
<div class="thumbnail">
<img src="{{path}}" alt="imagefail" style="width:100%">
<div>
<h3 style="">{{title}}</h3>
<button class="copyButton btn btn-primary btn-block"><i class="fa fa-clipboard" aria-hidden="true"></i>&#160Copy</button>
<button class="deleteButton btn btn-danger btn-block"><i class="fa fa-trash-o" aria-hidden="true"></i>&#160Delete</button>
</div>
</div>
</li>
{{/each}}
</ul>
</div>
</section>
I tried using a div.row instead of unordered list and for every image a div.col-md-3 and it has the same result:
<div class="row">
{{#each pictures}}
<div class="list-group-item col-md-3 col-xs-6 col-sm-6">
....
</div>
{{/each}}
</div>
Do you know any solution that does not require using a row for every 4 columns?
Fix the height of the images and it will work fine.
<div class="row">
{{#each pictures}}
<div class="col-md-3 col-xs-6 col-sm-6">
<img src="{{path}}" alt="imagefail" style="width:100%; height:200px">
</div>
{{/each}}
</div>

Bootstrap: Column White Space Text Fill

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>