HTML CSS Table positioning within a div - html

I have the below working example which I need tweaking slightly:
As you can see there are two centre aligned Tables. With a list of vertical buttons below left aligned.
The tables can have different numbers of <tr>'s and I want the tables to be equally aligned at the top not from the bottom. I.e. I want no gap at the top of the table 2. Does anyone know how I can amend this?
https://jsfiddle.net/Jaron787/gg30jgh5/16/
HTML
<div id="lse" class="display">
<div id="centertbl">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
<tr>
<td align="center" colspan="4">Data 1</td>
</tr>
<tr>
<td align="center" colspan="4">Data 2</td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
<tr>
<td align="center" colspan="4">Data 1</td>
</tr>
</table>
</div>
<input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2">
<input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4">
</div>
CSS
.TSS {
border: 1px solid #000000;
float: none;
font-family: Verdana,Geneva,sans-serif;
font-size: 10.6px;
font-style: normal;
padding: 10px;
text-decoration: none;
display: inline-block;
}
#centertbl {
text-align: center;
}
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}

Add this to your .TSS class:
vertical-align: top;
I have added it to your code below; try running it:
.TSS {
border: 1px solid #000000;
float: none;
font-family: Verdana,Geneva,sans-serif;
font-size: 10.6px;
font-style: normal;
padding: 10px;
text-decoration: none;
display: inline-block;
vertical-align: top;
}
#centertbl {
text-align: center;
}
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}
<div id="lse" class="display">
<div id="centertbl">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
<tr>
<td align="center" colspan="4">Data 1</td>
</tr>
<tr>
<td align="center" colspan="4">Data 2</td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
<tr>
<td align="center" colspan="4">Data 1</td>
</tr>
</table>
</div>
<input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2">
<input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4">
</div>

Related

How to remove grey "border" on HTML buttons

I am seeing a border around my buttons on an HTML webpage. I am trying to make one button blue and one green and they are placed in a table. Code below:
<table align="center">
<tr style=" font-family: verdana; font-size: 24px;">
<th> Select your Region </th>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td align="center">
<button>
<a id="cust" type="button"
style=
"background-color: #00824A;
border: none;
color: white;
padding: 16px 55px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
font-weight: bold;
font-family: verdana"
href="URL">
US
</a>
</button>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td align="center">
<button>
<a id="cust" type="button"
style=
"background-color: #0061D5;
border: none;
color: white;
padding: 16px 55px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
font-weight: bold;
font-family: verdana"
href="URL">
EU
</a>
</button>
</td>
</tr>
</table>
This is how they are showing up on the webpage:
I was expecting the whole button to be that color without the grey around the sides of it. I removed the "border" with border: none in the styles. Instead, it shows a rectangle of the color within the larger grey button.
The border is the button element itself, not the link <a> you've got inside of it. You need to style the button and remove the default border with <button style="border: none;">
Relevant reading: https://css-tricks.com/overriding-default-button-styles/
<table align="center">
<tr style=" font-family: verdana; font-size: 24px;">
<th> Select your Region </th>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td align="center">
<button style="border: none;">
<a id="cust" type="button"
style=
"background-color: #00824A;
border: none;
color: white;
padding: 16px 55px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
font-weight: bold;
font-family: verdana"
href="URL">
US
</a>
</button>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td align="center">
<button style="border:none;">
<a id="cust" type="button"
style=
"background-color: #0061D5;
border: none;
color: white;
padding: 16px 55px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
font-weight: bold;
font-family: verdana"
href="URL">
EU
</a>
</button>
</td>
</tr>
</table>

Content in absolute positioned div is overflowing

I have a weird question, and perhaps it's more suitable for the CSS fans out there, but why would content inside an absolute positioned div overflow out past everything else?
The example provided here (as a picture) shows that the content overflows out the blue bordered div. The content inside this box should rightfully define the the div's height no? How can this be remedied so that my 'blue' box fits to its content?
Here's the markup in question:
* {
box-sizing: border-box;
font-family: Verdana, Arial, sans-serif;
font-size: 9pt;
}
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
height: 100%;
background: rgb(105, 105, 105);
}
#table-container {
display: table;
text-align: center;
width: 100%;
height: 100%;
}
#container {
display: table-cell;
vertical-align: middle;
}
#wrapper {
padding: 25px;
}
.tabs {
position: relative;
margin: 40px 0 25px;
}
.tab {
float: left;
}
.tab label {
background: rgb(105, 105, 105);
padding: 10px;
border: 1px solid transparent;
color: #FFF;
margin-left: -1px;
position: relative;
left: 1px;
top: -26px;
}
.tab label:hover {
background: #000;
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: -1px;
left: 0;
background: rgb(222, 222, 222);
right: 0;
bottom: 0;
padding: 20px;
border: 1px solid transparent;
opacity: 0;
color: rgb(58, 58, 58);
}
[type=radio]:checked~label {
background: rgb(222, 222, 222);
font-weight: bold;
border-bottom: 1px solid transparent;
color: #000;
z-index: 2;
}
[type=radio]:checked~label~.content {
z-index: 1;
opacity: 1;
}
/* CSS for Table and Field styling */
.table {
width: 100%;
padding: 0;
margin: 0;
text-align: left;
}
.table td {
border: 1px solid #000;
}
.inputbox {
border: 1px solid rgb(170, 170, 170);
width: 100%;
}
.inputbox:hover {
border: 1px solid rgb(109, 109, 109);
}
.input {
border-style: none;
border-color: inherit;
border-width: 0;
padding: 3px;
height: 20px;
}
input[type="text"],
textarea {
width: 100%;
box-sizing: border-box;
}
.input:focus {
background: rgb(255, 255, 196);
}
<div id="table-container">
<div id="container">
<div id="wrapper">
<div style="border: 1px solid red; text-align: left; font-size: 8pt; color: #fff;">Choose language/Choisissez langue:</div>
<div style="border: 1px solid blue; height: 100%;">
<div class="tabs">
<!-- TAB [1] -->
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked><label for="tab-1">English</label>
<div class="content">
<table class="table">
<tr>
<td>Traveller's Name:</td>
<td colspan="2">
<div class="inputbox"><input type="text" id="tname" class="input" name="Name of Traveler" tabindex="1" /></div>
</td>
<td style="width: 15%;"></td>
<td>Tan #:</td>
<td></td>
</tr>
<tr>
<td>Destination:</td>
<td colspan="2">
<div class="inputbox"><input type="text" id="location" class="input" name="Location" tabindex="2" /></div>
</td>
<td></td>
<td>Status:</td>
<td></td>
</tr>
<tr>
<td>iTravel Trip Number:</td>
<td colspan="2">
<div class="inputbox"><input type="text" id="location" class="input" name="Location" tabindex="2" /></div>
</td>
<td></td>
<td>Date Issued:</td>
<td>
<div class="inputbox"><input type="text" id="dissued" class="input" disabled/></div>
</td>
</tr>
<tr>
<td>Event Plan ID Code:</td>
<td colspan="2">
<div class="inputbox"><input type="text" id="evt-plan-code" class="input" name="Event Plan ID Code" tabindex="4" /></div>
</td>
<td></td>
<td>Issued by:</td>
<td>
<div class="inputbox"><input type="text" id="issuer" class="input" disabled/></div>
</td>
</tr>
<tr>
<td>Dates of Travel</td>
<td>From:</td>
<td>
<div id="ddate" name="Departure Date" tabindex="5"></div>
</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> </td>
<td>To:</td>
<td>
<div id="rdate" name="Return Date" tabindex="6"></div>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Trip Purpose</td>
<td colspan="3"></td>
<td></td>
<td></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1"><label for="tab-2">Français</label>
<div class="content">
tab2
</div>
</div>
</div>
</div>
<div style="border: 1px solid green; text-align: left;">
<input type="button" value="Issue TAN" id="issue">
<input type="button" value="Reset form" id="issue">
<input type="button" value="Save changes" id="issue">
</div>
</div>
<!-- end of div #wrapper -->
</div>
<!-- end of div #container -->
</div>
<!-- end of div #table-container -->
The absolute-positioned div doesn't affect the container div's size since setting position to absolute removes it from the document flow. It's essentially the same behaviour as when position is set to fixed, except it stays at the same place in the page when you scroll. More info can be found here and here.
As for how to fix the height of your div, the short answer is that it can't be done with CSS unless you use a different value for position, perhaps relative in your case but that will depend on the structure of your html. This question covers some other ways that you could go about it.

Table cell button issue

I am facing an issue with a button set in a table cell which covers two rows. it does not fill the second row. how can i make this button fill both rows? I have tried to set height in the style of the button as well as on the table cell itself without success. Please see my code is below:
1) the css style of the button:
.button {
padding: 5px 15px;
font-size: 1.1em;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 1px;
box-shadow: 0 2px #999;
width: 100%;
vertical-align: middle;
}
And 2) my html table below:
<tr>
<td rowspan="2">
<button href="#0" class="button" id="cancel_order">Aκύρωση</button>
</td>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Εκτύπωση</button>
</td>
<td rowspan="2">
<button class="button">Παραγγελία</button>
</td>
</tr>
<tr>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Απόδειξη</button>
</td>
</tr>
In my opinion you should use css3 flexbox to achieve this as shown below:
.btn-holder {
display: flex;
}
.btn-holder .btn-holder {
flex-direction: column;
}
.button {
margin: 0 5px 5px 0;
padding: 5px 15px;
font-size: 1.1em;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 1px;
box-shadow: 0 2px #999;
}
<div class="btn-holder">
<button class="button" id="cancel_order">Aκύρωση</button>
<div class="btn-holder">
<button class="button">Εκτύπωση</button>
<button class="button">Παραγγελία</button>
</div>
<button class="button">Απόδειξη</button>
</div>
https://jsfiddle.net/k5wefqz5/1/
Is this your expected result ?
You miss <table> tag to complete your code.
Add this:
button {height:100%; }
Wrap table elements inside a <table> in order to get <td> and <tr> to behave as expected.
SNIPPET
table {
border: 1px solid red;
}
td {
border: 1px solid black;
}
button {
height: 100%;
}
<table>
<tr>
<td rowspan="2">
<button href="#0" class="button" id="cancel_order">Aκύρωση</button>
</td>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Εκτύπωση</button>
</td>
<td rowspan="2">
<button class="button">Παραγγελία</button>
</td>
</tr>
<tr>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Απόδειξη</button>
</td>
</tr>
</table>

HTML centre align Tables in Div with button list below

I want to centre align a number of tables next to each other at the top in the middle of a div. Underneath these tables I want to have a list of vertical buttons left aligned. I have tried many different techniques but none of which seem to work. Please could someone help?
Current Fiddle Example:
https://jsfiddle.net/Jaron787/gg30jgh5/
CSS
.TSS {
font-family: Verdana, Geneva, sans-serif;
font-size: 10.6px;
font-style: normal;
text-decoration: none;
float: left;
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
border: 1px solid black;
}
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}
HTML
<div id="lse" class="display">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
</table>
<input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2">
<input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4">
</div>
Probably just create a wrapper around the tables.
<div id="centertbl">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
</table>
Then apply the text-align to center.
#centertbl { text-align: center;}
That will center the tables in middle. Removed the margin: 0 auto; from the class .TSS.
Change the button css code from display: inline-block; to display: block;
jsFiddle : https://jsfiddle.net/gg30jgh5/6/
I think you need this type of css:
please check updeted fiddle link:
some changes in your html structure.table is one div and button is another sepreate div.
https://jsfiddle.net/gg30jgh5/9/
Set both tables inside a div and set margin-left:50% for this div
Set all buttons inside a div and set clear:both for this div.

IE 9 table spacing issue

The issue is that for some reason when in IE 9 (non-compatibility mode) one of the tds cause a goofy alignment. In this fiddle http://jsfiddle.net/2x3k3y5e/1/ the leftside button is fine it is the first of the right side buttons. For some reason it will not set on the right side. This is a part of user control (button bar) that will create various buttons for a page. ONLY in IE 9 have we noticed this issue. I would like to fix it everywhere and was hoping to use some css for this.
<table style="margin-top:10px;" cellspacing="0" cellPadding="0">
<tbody>
<tr>
<td noWrap="nowrap"> </td>
<td style="width: 100%;">
<input style="width: 125px;" id="BottomButtonBar_btnDelete" class="btnEntry" name="m$c$PatientSearchUC$PanelSearch$PanelSearch_BBB$BottomButtonBar_btnDelete" value="Previous Criteria" type="button"/>
</td>
<td style="padding-left: 4px;">
<input style="font-weight: normal; " id="BottomButtonBar_btnUpdate" class="btnEntry" value="Clear" type="button"/>
</td>
<td style="padding-left: 4px;">
<input style="width: 65px; font-weight: bold;" id="BottomButtonBar_btnUpdateAndReturn" class="btnPrimary btnEntry" value="Search" type="submit"/>
</td>
</tr>
</tbody>
</table>
CSS:
.btnEntry, .btnNav, .btnPrimary, .btnDefault{
text-transform: none;
cursor: pointer;
padding-right: 0;
padding: 6px 12px;
margin-left:0;
margin-right:0;
color: #000000;
min-width:60px;
}
.btnNav {
background-color: #fff;
border: #ccc 1px solid;
}
.btnEntry {
background-color: #ccc;
/*border: #b2b2b2 1px solid;*/
border: #ababab 1px solid;
color: #404040;
min-width:60px;
}
.btnDefault {
background-color: #ccc;
border: #ababab 1px solid;
color: #404040;
}
.btnPrimary {
color: #ffffff;
background-color: #82a83d;
}
If I set the size it is fine, but I don't think that using jquery to reset the size of a button to it's same size is a good solution. Again I am hoping there is some css trick that I don't know about to fix this. Thanks.
Side Note: I use IETester or a VM with Windows and IE 9
Try Float:right:
HTML:
<table style="margin-top:10px;" cellspacing="0" cellPadding="0">
<tbody>
<tr>
<td noWrap="nowrap"> </td>
<td style="width: 100%;">
<input style="width: 125px;" id="BottomButtonBar_btnDelete" class="btnEntry" name="m$c$PatientSearchUC$PanelSearch$PanelSearch_BBB$BottomButtonBar_btnDelete" value="Previous Criteria" type="button"/>
</td>
<td style="padding-left: 4px;">
<input style="font-weight: normal; " id="BottomButtonBar_btnUpdate" class="btnEntry btnClear" value="Clear" type="button"/>
</td>
<td style="padding-left: 4px;">
<input style="width: 65px; font-weight: bold;" id="BottomButtonBar_btnUpdateAndReturn" class="btnPrimary btnEntry" value="Search" type="submit"/>
</td>
</tr>
</tbody>
</table>
CSS:
.btnEntry, .btnNav, .btnPrimary, .btnDefault{
text-transform: none;
cursor: pointer;
padding-right: 0;
padding: 6px 12px;
margin-left:0;
margin-right:0;
color: #000000;
min-width:60px;
}
.btnClear{
float:right;
}
.btnNav {
background-color: #fff;
border: #ccc 1px solid;
}
.btnEntry {
background-color: #ccc;
/*border: #b2b2b2 1px solid;*/
border: #ababab 1px solid;
color: #404040;
min-width:60px;
}
.btnDefault {
background-color: #ccc;
border: #ababab 1px solid;
color: #404040;
}
.btnPrimary {
color: #ffffff;
background-color: #82a83d;
}