how to set a button sit next to a table within a div.
my code is:
<div class="col-xs-6"> <!-- main div -->
<div> <!-- table div -->
<table class="table table-bordered table-striped text-center">
<thead><tr>
<!-- 4 Header -->
</tr></thead>
<tbody> <tr><td>
<!-- first row -->
</td></tr></tbody>
</table>
</div>
<div class="col-xs-4">
<div class="col-xs-2" >
<button type="button" class="btn btn-primary" name="search" id="search">Search</button>
</div>
<div class="col-xs-2" >
<button type="button" class="btn btn-primary" name="add" id="add">Add</button>
</div>
</div>
-- main div close
what i am getting is:
put the main div to class: col-xs-12
and button div to col-xs-8 or col-xs-10.
So, main is total 12 in which you are putting the Table with *-xs-2 and button with *-xs-8
Try this
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container">
<div class="row">
<div class="col-xs-4">
<table class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
</tbody>
</table>
</div>
<div class="col-xs-8">
<div class="row">
<div class="col-xs-3" >
<button type="button" class="btn btn-primary" name="search" id="search">Search</button>
</div>
<div class="col-xs-3" >
<button type="button" class="btn btn-primary" name="add" id="add">Add</button>
</div>
</div>
</div>
</div>
</div>
Check this out: https://jsfiddle.net/hbp71ejr/
Related
I have three divs, where the first two have to be fixed and the third scroll. I'm doing it this way:
.topo2 {
position: fixed;
width: 95%;
z-index: 10;
top: auto;
bottom: auto;
}
.topo6 {
position: fixed;
width: 95%;
z-index: 10;
bottom: auto;
}
.acerto{
overflow:auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="topo2">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="content">
<div class="zero-clipboard"><h3><span class="btn-clipboard with-example" style="color:#03a9f4">ORÇAMENTOS</span></h3></div>
<div style="clear:both;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="topo6">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="content">
<div class="box-table">
<table id="taborc3" class="table">
<thead>
<tr>
<th class="table__heading acerto2"><i class="fa fa-pencil"></i></th>
<th class="table__heading acerto3">Orçamento</th>
<th class="table__heading acerto4">Referência</th>
<th class="table__heading acerto5">Designação</th>
<th class="table__heading acerto6">Quantidade</th>
<th class="table__heading acerto7">Unidade</th>
<th class="table__heading acerto8">Preço Unitário</th>
<th class="table__heading acerto9">Valor</th>
<th class="table__heading acerto10">Nota de Encomenda</th>
<th class="table__heading acerto11">Fornecedor</th>
<th class="table__heading acerto12">Previsão de Entrega</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="clear:both;"></div>
<div class="container-fluid acerto">
<div class="row">
<div class="col-md-12">
<div class="content1">
<table id="taborc1" class="table">
<tbody>
</tbody>
</table>
<button type="button" class="btn btn-raised btn-default ripple-effect" id="taborc2" style="float: right;" onclick="update_orped(); ins_orped(); update_entreg();">Gravar <i class="fa fa-paper-plane"></i></button>
</div>
</div>
</div>
</div>
But the first two divs that have to be fixed are on top of each other.
I intend the second div to be after the first div and not on top of the other. I know that if you set the top property in the css and manually adjust it with it, but the first and second dives are not always the same height.
They can have two lines with having ten lines. How do I dynamically distinguish this so that the second div appears after the first without using the top property?
I've tried the bottom and margin-bottom properties but they don't work
Add a 'wrapper' element around the first two fixed divs, and set that one to fixed.
<div class="fixed-container">
<div class="topo2">...</div>
<div class="topo6">...</div>
</div>
.fixed-container{
position: fixed;
}
(function ($) {
$(function () {
$( window ).resize(function() {
setPadding();
});
setPadding();
function setPadding() {
let pad = ($('.fixed-container').height() + 10) + 'px';
$('.acerto').css('padding-top', pad);
}
});
})(jQuery);
.fixed-container{
position: fixed;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="fixed-container">
<div class="topo2">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="content">
<div class="zero-clipboard"><h3><span class="btn-clipboard with-example" style="color:#03a9f4">ORÇAMENTOS</span></h3></div>
<div style="clear:both;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="topo6">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="content">
<div class="box-table">
<table id="taborc3" class="table">
<thead>
<tr>
<th class="table__heading acerto2"><i class="fa fa-pencil"></i></th>
<th class="table__heading acerto3">Orçamento</th>
<th class="table__heading acerto4">Referência</th>
<th class="table__heading acerto5">Designação</th>
<th class="table__heading acerto6">Quantidade</th>
<th class="table__heading acerto7">Unidade</th>
<th class="table__heading acerto8">Preço Unitário</th>
<th class="table__heading acerto9">Valor</th>
<th class="table__heading acerto10">Nota de Encomenda</th>
<th class="table__heading acerto11">Fornecedor</th>
<th class="table__heading acerto12">Previsão de Entrega</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="clear:both;"></div>
<div class="container-fluid acerto">
<div class="row">
<div class="col-md-12">
<div class="content1">
<table id="taborc1" class="table">
<tbody>
</tbody>
</table>
<button type="button" class="btn btn-raised btn-default ripple-effect" id="taborc2" style="float: right;" onclick="update_orped(); ins_orped(); update_entreg();">Gravar <i class="fa fa-paper-plane"></i></button>
</div>
</div>
</div>
</div>
$(window).on('load resize', function(){
var fixedCon = $('.fixed-container').outerHeight();
$('.acerto').css('margin-top',fixedCon);
});
.fixed-container{
position: fixed;
width: 95%;
z-index: 10;
top: 0;
}
.acerto{
overflow:auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="fixed-container">
<div class="topo2">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="content">
<div class="zero-clipboard"><h3><span class="btn-clipboard with-example" style="color:#03a9f4">ORÇAMENTOS</span></h3></div>
<div style="clear:both;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="topo6">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="content">
<div class="box-table">
<table id="taborc3" class="table">
<thead>
<tr>
<th class="table__heading acerto2"><i class="fa fa-pencil"></i></th>
<th class="table__heading acerto3">Orçamento</th>
<th class="table__heading acerto4">Referência</th>
<th class="table__heading acerto5">Designação</th>
<th class="table__heading acerto6">Quantidade</th>
<th class="table__heading acerto7">Unidade</th>
<th class="table__heading acerto8">Preço Unitário</th>
<th class="table__heading acerto9">Valor</th>
<th class="table__heading acerto10">Nota de Encomenda</th>
<th class="table__heading acerto11">Fornecedor</th>
<th class="table__heading acerto12">Previsão de Entrega</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="clear:both;"></div>
<div class="container-fluid acerto">
<div class="row">
<div class="col-md-12">
<div class="content1">
<table id="taborc1" class="table">
<tbody>
</tbody>
</table>
<button type="button" class="btn btn-raised btn-default ripple-effect" id="taborc2" style="float: right;" onclick="update_orped(); ins_orped(); update_entreg();">Gravar <i class="fa fa-paper-plane"></i></button>
</div>
</div>
</div>
</div>
First you need to store top div height in variable after then you can add top using stored value on window load and resize function so it will automatic set top position according to first div height. Please check demo.
<div class="col-md-12" style="padding: 10px">
<div class="card m-b-30">
<div class="card-header container-fluid" ">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-12 table-responsive">
<div id="order-listing_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer">
<div class="row">
<div class="col-md-12">
<table id="order-listing" class="table dataTable no-footer table-striped" style="border-bottom:1pt solid black" role="grid" aria-describedby="order-listing_info">
<thead>
<tr role="row">
<th width="70%"><b>Name</b></th>
<th><b>Active</b></th>
<th><b>Select</b></th>
<th><b>Delete</b></th>
</tr>
</thead>
<tbody>
#*#foreach (var item in Model)
{*#
<tr>
<td>
<div class="input-group">
<input type="text" class="form-control" placeholder="Search here" style="width: 450px; height: 40px">
<div class="input-group-append">
<button class="btn btn-secondary" type="button">
<i class="dripicons-search"></i>
</button>
</div>
</div>
</td>
<td>
<input type="checkbox" name="checkbox2">
</td>
</tr>
<tr>
<td>Test New</td>
<td><input class="form-check-input" type="checkbox" id="gridCheck"></td>
<td><button type="button" class="btn btn-icons btn-inverse-secondary" id="data-editbtn-id"><div><i class="icon-pencil"></i></div></button></td>
<td><button type="button" class="btn btn-icons btn-inverse-secondary" id="data-delete-id"><div><i class="dripicons-trash"></i></div></button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I tried aligning this checkbox with the Active column but my code doesn't align it with the specified column
whats wrong with my code?
some online HTML generates output the correct code with same code but when i edit it, the aligned doesn't work properly
I have attached my code above can anyone help me im using html and css for this.
Please give the below CSS, the input element is taking CSS of margin-left.
.form-check-input{
margin:0 !important;
}
And also give this CSS
.table td, .table th{
vertical-align: middle;
}
I have this html page:
<div class="panel panel-default">
<div class="panel-heading">
<h1>Usuarios</h1>
</div>
<div class="panel-body">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Nome</th>
<th>Telefone</th>
<th>Email</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let usuario of usuarios | async">
<td>{{usuario.nome}}</td>
<td>{{usuario.telefone}}</td>
<td>{{usuario.email}}</td>
<td><button (click)="deleteUsuario(usuario.id)" class="btn btn-danger">Delete</button>
<button (click)="updateUsuario(usuario.id)" class="btn btn-info" style="margin-left: 10px">Update</button></td>
</tr>
</tbody>
</table>
</div>
</div>
The width is following the navbar, so it's being stretched all the screen:
How can I reduce it to the center of the screen like a have a margin before and after the form?
I want it to be like this:
Looking at your screenshot I guess you are using Materialize CSS:
Try to the form code within below code:
<div class="container">
<div class="col s12">
<div class="panel panel-default">
<div class="panel-heading">
<h1>Usuarios</h1>
</div>
<div class="panel-body">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Nome</th>
<th>Telefone</th>
<th>Email</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let usuario of usuarios | async">
<td>{{usuario.nome}}</td>
<td>{{usuario.telefone}}</td>
<td>{{usuario.email}}</td>
<td><button (click)="deleteUsuario(usuario.id)" class="btn btn-danger">Delete</button>
<button (click)="updateUsuario(usuario.id)" class="btn btn-info" style="margin-left: 10px">Update</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
Just add this style code:
form {
max-width: 900px;
margin-left: auto;
margin-right: auto
}
first of all: I know a similar question was already asked, several times. I read and tried the suggested solutions and they work in favor of the error message of my IDE.
But if I add the style to the header -like solutions suggest-, it will no longer work for my bootstrap button.
<style>.btn:focus, .btn:active {
outline: none !important;
box-shadow: none !important;
}</style>
If I inline the code it works.
<button type="button" class="btn btn-outline-primary btn-sm" data-toggle="modal" data-target="#myModal" data-th-id="${person.getId()}" style="outline:none;box-shadow:none;">
If I add the style to the body, it also applies the effect I want.
So I am interested how to make this W3C conform and working without inlining it.
This is how it works but complaining IDE
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head th:replace="template :: head">
</head>
<body>
<!-- start header -->
<!-- Fixed navbar -->
<div th:replace="template :: navbar"></div>
<!-- end header -->
<!--- start table -->
<div class="container">
<div>
<style>.btn:focus, .btn:active {
outline: none !important;
box-shadow: none !important;
}</style>
</div>
<br>
<h3>Overview</h3>
<br>
<div class="container">
<div class="col-12">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Age</th>
<th scope="col">ID</th>
</tr>
</thead>
<tbody>
<!--/*#thymesVar id="productList" type="java.util.List"*/-->
<tr th:id="${person.getId()}" th:each="person : ${elementList}">
<td th:text="${person.getName()}" class="username"></td>
<!--/*#thymesVar id="getTradableBTC" type="java.lang.Double"*/-->
<td th:text="${person.getAge()}" class="age"></td>
<!--/*#thymesVar id="getTop" type="java.lang.Double"*/-->
<td th:text="${person.getId()} " class="id"></td>
<td>
<div class="btn-toolbar" role="toolbar">
<!-- Button trigger modal -->
<div class="btn-group mr-2" role="group" aria-label="First group">
<button type="button" class="btn btn-outline-primary btn-sm" data-toggle="modal"
data-target="#myModal" data-th-id="${person.getId()}">
Edit
</button>
</div>
<div class="btn-group mr-2" role="group" aria-label="Second group">
<button type="button" class="btn btn-outline-danger btn-sm" id="delete">Delete
</button>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<button class="btn btn-primary" type="button" id="addElement">Add Element</button>
<button class="btn btn-light" type="button" id="DeleteAll">Delete all Elements</button>
</div>
</div>
I see two issues with my code. Header is not getting fixed and second issue is word wrap is not applicable for the headers/rows.
I have used bootstrap classes, but still facing issues. I want to fix the table header and only rows should be scrollable and if the text is long it should automatically word wrap. I have multiple columns in my application(approximately 15 columns).Please advice.
To view the sample code click here.
Sample html code:
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body" id="modal-body">
<table id="myTable" class="table table-fixedheader table-bordered table-striped">
<thead>
<tr class="row">
<th class="col-md-3">Header1</th>
<th class="col-md-4">Header2Header2Header2Header2</th>
<th class="col-md-3">Header3</th>
<th class="col-md-4">Header4</th>
</tr>
</thead>
<tbody>
<tr class="row">
<td class="col-md-3">111111111111111111111111111111111111111111111111111111111111111111111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">5443545435354543</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">5437665</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">5435435443</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">68678454</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">786876</td>
<td class="col-md-3">8787876</td>
<td class="col-md-4">6765767</td>
</tr>
<tr class="row">
<td class="col-md-3">7656765</td>
<td class="col-md-4">656456</td>
<td class="col-md-3">116611</td>
<td class="col-md-4">43434</td>
</tr>
<tr class="row">
<td class="col-md-3">43243432434324342</td>
<td class="col-md-4">33344343233</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">4343</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">432434343243243</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">432443</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">333333</td>
<td class="col-md-3">111312312123121</td>
<td class="col-md-4">32112</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
You could try a non table approach. If your ok with having set widths on the columns with content wrapping in the cells. Here's an example https://codepen.io/flurrd/pen/jmMNxK?editors=1100
Note: Class names are terrible in this example. I'd BEM it up for proper usage.
.table-body {
max-height: 200px;
overflow-y:auto;
}
.t-row {
display: flex;
border-bottom: 1px solid grey;
}
.t-row:nth-child(even){
background: #e3e3e3;
}
.col {
word-wrap: break-word;
flex: 1 0 30%;
max-width: 33.3333%;
}
.cell {
padding: 8px;
}
<div class="table-wrap">
<div class="t-row t-header">
<div class="col">
<div class="cell">
Header 1
</div>
</div>
<div class="col">
<div class="cell">
Header 1
</div>
</div>
<div class="col">
<div class="cell">
Header 1
</div>
</div>
</div>
<div class="table-body">
<div class="t-row">
<div class="col">
<div class="cell">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
</div>
<div class="col">
<div class="cell">
1111
</div>
</div>
<div class="col">
<div class="cell">
11111111
</div>
</div>
</div>
</div>
</div>