Below here is the code that I wrote. I wanted a page with 3 table cells, where left one will be one table cell with 50% width of the page, and the right cell will be divided into 2 cells each with 50% height. The code below works partially fine.
The issue is the right 2 cells width gets reduced(screenshot attached). Can't figure out how to get the width to work :")
<div style="display: table; width: 100%; height:100%;">
<div style="display: table-row;">
<div style="display: table-cell; width: 50%; border-style: ridge; height: 713px">
<?php
foreach($doctors as $entry)
{
echo '<div style="display: table-row; width=100%;">
<div style="display:table-cell; width:25%;">
<p style="margin-left:10px;">'.$entry["name"].'</p>
</div><div style="display:table-cell; width:20%;">
<p>'.$entry["id"].'</p>
</div><div style="display:table-cell; width:20%;">
<p>'.$entry["designation"].'</p>
</div><div style="display:table-cell;">
<p>'.$entry["salary"].'<button class="btn" name='.$entry["id"].' style="margin-left:100px; width;">Edit salary</button></p>
</div>
</div>';
}
?>
</div>
<div style="display: table-cell; width: 100%;">
<div style="display: table-row;">
<div style="display: table-cell;">
<center>
<form style="border-style: ridge; height: 350px; padding-top: 17px;">
<label class="text" for="id">Enter ID: </label>
<input id="text-box" class="text" type="text" name="id" placeholder="Enter id"><br>
<button id="btn" class="text">Search</button>
</form>
</center>
</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell;">
<center>
<form style="border-style: ridge; height: 350px; padding-top: 17px;">
<label class="text" for="id">Enter ID: </label>
<input id="text-box" class="text" type="text" name="id" placeholder="Enter id"><br>
<button id="btn" class="text">Search</button>
</form>
</center>
</div>
</div>
</div>
</div>
</div>
I want to make a html page with three sections and inside each section divide it to left and right. In each section I have three boxes and I want to put two boxes on the left and one box on the right following is the css and html code:
.leftbox {
width: 50%;
padding: 5px;
float: left;
}
.rightbox {
width: 50%;
padding: 5px;
float: right;
}
<div id="rotationFormPopup" class="rotationFormPopup" style="width: 900px; display: none; background: #FFF; border: 1px solid; padding: 10px; margin-top: 100px;">
<h2 class="popup-header">Rotation Forms</h2>
<div class="newRotation-sections">
<h3>Details</h3>
<div class="newRotation-section-1" style="margin-top: 10px;">
<div class="leftbox">
<span>Mob</span> <br />
<input type="text" class="newRotation-mob" style="width: 100%;"><br /><br />
<span>Paddock</span> <br />
<input type="text" class="newRotation-paddock" style="width: 100%;"><br /><br />
</div>
<div class="rightbox">
<span>Date</span> <br />
<input type="text" class="newRotation-date" style="position: relative; display: inline-block; float: left; width: 100%; margin-top: 10px;"><br /><br />
</div>
</div>
<h3>Fencing options</h3>
<div class="newRotation-section-2" style="margin-top: 10px;">
<div class="leftbox">
<span>Available Today</span> <br />
<input type="text" class="newRotation-available" style="width: 100%;"><br /><br />
<span>Paddock Allocation %</span> <br />
<input type="number" class="newRotation-alloc" value="50" style="width: 100%;"><br /><br />
</div>
<div class="rightbox">
<span>Required Result</span> <br />
<input type="text" class="newRotation-result" style="width: 100%;"><br /><br />
</div>
</div>
<h3>Assign As Task</h3>
</div>
</div>
</div>
I receive the below result, I don't know why the fencing options jump to the right side.
Here is the image of my work:
I wrote up this using the Bootstrap Framework. It matches your image exactly.
There's a Codepen if you want to fork and play around with it. It's responsive, too.
/* Roboto Font */
#import url('https://fonts.googleapis.com/css?family=Roboto');
html, body {
height: 100%;
}
body {
font-family: 'Roboto', sans-serif;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" type="text/css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
<div class="container p-5">
<div class="row">
<div class="col-sm-12">
<h5 class="title text-uppercase bg-success text-white p-1">Rotation Forms</h5>
<h4 class="mb-3 mt-3">Details</h4>
</div>
<div class="col-sm-12 col-md-6">
<div class="form-group">
<label for="mob">Mob</label>
<input type="text" class="form-control" id="mob" placeholder="Enter Mob">
</div>
<div class="form-group">
<label for="paddock">Paddock</label>
<input type="text" class="form-control" id="paddock" placeholder="Enter Paddock">
</div>
</div>
<div class="col-sm-12 col-md-6">
<div class="form-group">
<label for="date">Date</label>
<input type="date" class="form-control" id="date" placeholder="Enter Date">
</div>
<h4 class="mb-3 mt-3">Fencing Options</h4>
<div class="form-group">
<label for="avail">Available Today</label>
<input type="text" class="form-control" id="avail" placeholder="NaN">
</div>
<div class="form-group">
<label for="allocation">Paddock Allocation %</label>
<input type="number" class="form-control" id="allocation" placeholder="100">
</div>
<div class="form-group">
<label for="result">Required Result</label>
<input type="text" class="form-control" id="result" placeholder="NaN">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-6">
<h4 class="mb-3 mt-3">Assign As Task</h4>
<div class="form-group">
<label for="assign">Assign to</label><br>
<button type="submit" class="btn btn-success btn-md" id="assign">Add</button>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checked">
<label class="form-check-label" for="checked">I want to see this too.</label>
</div>
<button type="button" class="btn btn-success btn-md">Save</button>
<button type="button" class="btn btn-success btn-md">Cancel</button>
</div>
</div>
</div>
I am developing a JSF web project with primefaces 6.2.
I would produce a form having outputlabel above inputText.
Following a sample code using div.
How can I produce it using panel, panelGrid, row, column, outputLabel and inputText of primefaces? there have not been successful... Thanks!!
<div class="rows">
<div style="padding-top:5px;padding-bottom:5px;padding-left:10px;**strong text**loat:left">
<div>Name:</div>
<div>
<input id="name" type="text" style="height: 20px; width: 200px;" />
</div>
</div>
<div style="padding-top:5px;padding-bottom:5px;padding-left:10px;float:left">
<div>Surname:</div>
<div>
<input id="surname" type="text" style="height: 20px; width: 200px;" />
</div>
</div>
</div>
<div class="rows">
<div style="padding-top:5px;padding-bottom:5px;padding-left:10px;float:left">
<div>Address:</div>
<div>
<input id="address" type="text" style="height: 20px; width: 200px;" />
</div>
</div>
<div style="padding-top:5px;padding-bottom:5px;padding-left:10px;float:left">
<div>Email:</div>
<div>
<input id="email" type="text" style="height: 20px; width: 200px;" />
</div>
</div>
</div>
could you have a look at the HTML/CSS-code and result behind this link?
the CSS part:
div2 {display: table-cell; vertical-align: middle; border: 0px solid red; }
input {margin: 5px; }
label1 {margin-left: 140px; }
label2 {margin-left: 100px; }
label3 {margin-left: 90px; }
label {margin-left: 10px; margin-right: 20px; }
the HTML part:
<div1>
<label1>First name</label1>
<label2>Last name</label2>
<label3>Date of birth</label3>
</div1>
<div2>
<label for='name'>Person 1:</label>
<input type='text' id='name' />
<input type='text' id='name' />
<input type='text' id='name' />
<br>
<label for='name'>Person 2:</label>
<input type='text' id='name' />
<input type='text' id='name' />
<input type='text' id='name' />
<br>
<label for='name'>Person 3:</label>
<input type='text' id='name' />
<input type='text' id='name' />
<input type='text' id='name' />
<br>
<label for='name'>Person 4:</label>
<input type='text' id='name' />
<input type='text' id='name' />
<input type='text' id='name' />
<br>
<label for='name'>Person 5:</label>
<input type='text' id='name' />
<input type='text' id='name' />
<input type='text' id='name' />
</div2>
Is there a way to automatically align the labels on top so they exactly match with the colomns below? Looking forward to your suggestions. Regards, Piotr
use display: table or table
* {
padding;
0;
margin: 0;
}
.wrapper {
display: table;
table-layout: fixed;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
vertical-align: middle;
border: 0px solid red;
padding: 5px 10px;
vertical-align: middle;
}
.row:nth-child(1) {
text-align: center;
}
.row:nth-child(1) .cell {
padding-bottom: 0;
}
.row:nth-child(1) .cell label {
margin-bottom: 0;
}
input, label {
display: block;
width:100%;
margin: 5px 0;
}
label {
margin-left: 5px;
margin-right: 15px;
}
<div class="wrapper">
<div class="row">
<div class="cell"></div>
<div class="cell">
<label>First name</label>
</div>
<div class="cell">
<label>Last name</label>
</div>
<div class="cell">
<label>Date of birth</label>
</div>
</div>
<div class="row">
<div class="cell">
<label for='name'>Person 1:</label>
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
</div>
<div class="row">
<div class="cell">
<label for='name'>Person 2:</label>
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
</div>
<div class="row">
<div class="cell">
<label for='name'>Person 3:</label>
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
</div>
<div class="row">
<div class="cell">
<label for='name'>Person 4:</label>
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
</div>
<div class="row">
<div class="cell">
<label for='name'>Person 5:</label>
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
<div class="cell">
<input type='text' id='name' />
</div>
</div>
</div>
I am trying to design the layout in the below screenshot
I tried to implement the same in fiddle
http://jsfiddle.net/NNLct/1/
<div id="CorpDealerSearch" >
<div class="left"> DealerName </div>
<div class="left"> Region </div>
<div class="left"> DealerCode </div>
<div class="left"> Area </div>
<div class="left">
<input type="text"/>
</div>
<div class="left">
<input type="text"/>
</div>
<div class="left">
<input type="text"/>
</div>
<div class="left">
<input type="text"/>
</div>
</div>
Please help in suggesting proper css to get the design
Have a look at this FIDDLE
HTML
<div class='table'>
<div class='row'>
<div class='cell'>DealerName
<input type='text' />DealerCode
<input type='text' />
</div>
<div class='cell'>Region
<input type='text' />Area
<input type='text' />
</div>
</div>
</div>
CSS
body{
width:100%;
padding:0;
margin:0;
box-sizing:border-box;
}
.table {
display:table;
width:100%;
}
.row {
display:table-row;
}
.cell {
display:table-cell;
padding-right:20px;
}
input {
display:block;
width:100%;
}
Try something else:
http://jsfiddle.net/Ta6Qk/
HTML
<div class="main">
<div>
<label>Data</label>
<input type="text" value="">
</div>
<div>
<label>Data</label>
<input type="text" value="">
</div>
<div>
<label>Data</label>
<input type="text" value="">
</div>
<div>
<label>Data</label>
<input type="text" value="">
</div>
</div>
and CSS
.main {
width: 400px;
position: relative;
}
.main div {
border: none;
display: inline-block;
width: 44%;
margin-right: 3%;
}
input {
width: 100%;
}
label {
display:block
}
You have to include label and input in the same div:
http://jsfiddle.net/NNLct/5/
Don't forget you can also use label tags to associate the text to the related input.
<div id="CorpDealerSearch" >
<div class="left">
DealerName <input type="text"/>
</div>
<div class="left">
Region <input type="text"/>
</div>
<div class="left">
DealerCode <input type="text"/>
</div>
<div class="left">
Area <input type="text"/>
</div>
</div>
CSS:
.left
{
float:left;
}
Going by your existing markup, here is a : DEMO
Float the elements and after every 2 element, clear the floats, as simple as that!! :)
CSS
.left {
float:left
}
.clr{clear:both}
HTML
<div id="CorpDealerSearch">
<div class="left">DealerName
<br />
<input type="text" />
</div>
<div class="left">Region
<br />
<input type="text" />
</div>
<div class="clr"></div>
<div class="left">DealerCode
<br />
<input type="text" />
</div>
<div class="left">DealerCode
<br />
<input type="text" />
</div>
</div>
See this fiddle:
http://jsfiddle.net/NNLct/16/
Using display:table; display:table-row; display:cell;
Here's the fiddle:Check this
Here's the HTML Code:
<div id="container">
<div id="left" class="left">
<div id="top-left" class="innerdiv">
<div id="lbl-tl">
Dealer Name:
</div>
<div id="txt-tl">
<input type="text" style="width: 90%;" />
</div>
</div>
<div id="bottom-left" class="innerdiv">
<div id="lbl-bl">
Dealer Code:
</div>
<div id="txt-bl">
<input type="text" style="width: 90%;" />
</div>
</div>
</div>
<div id="right" class="right" >
<div id="top-right" class="innerdiv">
<div id="lbl-tr">
Region:
</div>
<div id="txt-tr">
<input type="text" style="width: 90%;" />
</div>
</div>
<div id="bottom-right" class="innerdiv">
<div id="lbl-br">
Area:
</div>
<div id="txt-br">
<input type="text" style="width: 90%;" />
</div>
</div>
</div>
</div>
And here's the CSS:
*
{
margin: 0px;
padding: 0px;
}
#container
{
width: 700px;
min-height: 150px;
}
.left
{
width: 49%;
min-height: 150px;
float: left;
}
.right
{
min-height: 150px;
width: 49%;
float: right;
}
.innerdiv
{
height: 75px;
}
First I would change the html to:
HTML
<div id="CorpDealerSearch" >
<div>
<label for="dealerName">DealerName</label>
<input type="text" id="dealerName" name="dealerName">
<label for="Region">Region</label>
<input type="text" id="Region" name="Region">
</div>
<div>
<label for="DealerCode">DealerCode</label>
<input type="text" id="DealerCode" name="DealerCode">
<label for="Area">Area</label>
<input type="text" id="Area" name="Area">
</div>
</div>
And the css would be:
CSS
#CorpDealerSearch label, input{
float:left;
clear:both;
}
#CorpDealerSearch div{
display:block;
float:left;
width:200px;
}
hope this will help.