I styled my radiobuttons using this tutorial:
a link
It works perfect without a tablelayout! But..
I have a fix tablelayout and I can not change anything on this layout (the layout comes from an old generator). The label and the inputtype (radiobutton) are in separate tables.
Have anyone a idea? How can I style the radiobutton inside the table?
My jsfiddle:
http://jsfiddle.net/ETp5w/
The HTML
<!-- Tablelayout .. is not working!!! -->
<table class="" width="100.0%" cellpadding="0" cellspacing="0">
<colgroup>
<col width="100.0%">
</colgroup>
<tbody>
<tr>
<td class="">
<table cellpadding="0" cellspacing="0" class="">
<tbody>
<tr>
<td>
<input type="radio" name="answer" value="1" class="abc" id="radiobutton1">
</td>
<td>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<label for="radiobutton1"><span class="spantext">answer1<br></span></label>
</td>
</tr>
</tbody>
</table>
</td>
<td class="next">
</td>
</tr>
</tbody>
</table>
<table cellpadding="0" cellspacing="0" class="">
<tbody>
<tr>
<td>
<input type="radio" name="answer" value="2" class="abc" id="radiobutton2">
</td>
<td>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<label for="radiobutton2"><span class="spantext">answer2<br></span></label>
</td>
</tr>
</tbody>
</table>
</td>
<td class="next">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- Same code without tables. Works! -->
<input id="answer3" type="radio" name="answer" value="3"></td>
<label for="answer3">answer3</label>
<input id="answer4" type="radio" name="answer" value="4">
<label for="answer4">answer4</label>
The CSS
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
width: 100%;
}
label:checked::before {
background-color: yellow;
}
input[type=radio] {
display: none;
}
label:before {
content: "";
display: inline-block;
width: 20px;
height: 20px;
margin-right: 10px;
position: absolute;
left: -15;
bottom: 1px;
background-color: #aaa;
box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
}
label:hover::before {
background-color: red;
}
input[type=radio]:checked + label:before {
content: "\2022";
color: blue;
font-size: 30px;
text-align: center;
line-height: 18px;
background-color: red;
}
.radio label:before {
border-radius: 8px;
}
Related
I am using this codes below to Add data into my web :
//Codes//
.AddData input {
font-size: 15px;
padding: 2.5px;
margin-bottom: 15px;
}
.AddData [type='text'] {
font-weight: bold;
font-size: 18px:
margin-bottom: 6px;
}
.AddData button {
transform: translate(120%,-50%);
outline: 1px solid black;
width: 80px;
height: 40px;
font-size: 16px;
background: #ff267e;
display: block;
cursor: pointer;
color: #fff;
border: none;
}
.AddData tr {
margin-bottom: auto;
}
Below is my html codes i used for my website.
//Html//
<link rel="stylesheet" type="text/css" href="web.css">
<body>
<div class ="AddData">
<form action="add.php" method="POST" name="form1">
<table width="25%" border="0">
<tr>
<td>User ID: </td>
<td><input type="text" name="User_id" required autocomplete="off"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="Password" required autocomplete="off"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="CPass" required autocomplete="off" ></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Add"></td>
</tr>
</table>
This is what it shows on my website i just need the 'User_id' to be inline as the input box.
https://i.stack.imgur.com/yBPEW.png
You have to use padding instead of margin to add space inside a td. I left some commented code for you to check what styles I removed from your code.
There will be some issues you'll have to fix like the difference in font size.
.AddData input {
font-size: 15px;
padding: 2.5px;
/* margin-bottom: 15px; */
}
.AddData [type='text'] {
font-weight: bold;
font-size: 18px; /*; was missing*/
/* margin-bottom: 6px; */
}
.AddData button {
transform: translate(120%,-50%);
outline: 1px solid black;
width: 80px;
height: 40px;
font-size: 16px;
background: #ff267e;
display: block;
cursor: pointer;
color: #fff;
border: none;
}
/* .AddData tr {
margin-bottom: 15px;
} */
.AddData td {
padding-bottom: 15px;
}
<body>
<div class ="AddData">
<form action="add.php" method="POST" name="form1">
<table width="25%" border="0">
<tr>
<td>User ID: </td>
<td><input type="text" name="User_id" required autocomplete="off"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="Password" required autocomplete="off"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="CPass" required autocomplete="off" ></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Add"></td>
</tr>
</table>
</form>
</div>
</body>
I am trying to align my table2 to the right using the align="right" attribute of table, however, it's not exactly aligning next to the table1, as shown in the JSFiddle here. Instead it is getting aligned next to the Third Heading which I don't want.
I want table 1 and table 2 to be next to one another and then Heading 3 should come below it.
Another issue, I was trying to resolve is the position of the Heading 2 with the float:right as shown below. It's not going to extreme right.
.enc-data-table {
margin: 0 0 45px 0;
}
.enc-data-table th {
font-size: 12pt;
/*font-weight: 700;*/
padding: 0 5px 5px 0;
text-align: right;
}
.enc-data-table td {
font-size: 12pt;
padding: 0 0 5px 0;
}
h3 {
font-size: 20px;
}
h3 {
width: 50%;
height: 40px;
margin: 0;
padding: 0;
display: inline;
}
hr {
width: 100%
}
<h3>Heading 1</h3>
<h3 style="float:right">Heading 2</h3>
<hr/>
<table class="enc-data-table">
<tr>
<th>Location:</th>
<td >A</td>
</tr>
<tr>
<th>Type:</th>
<td >B</td>
</tr>
<tr>
<th>Dates:</th>
<td >Today</td>
</tr>
<tr>
<th>Reason for visit:</th>
<td >D</td>
</tr>
</table>
<table align= "right" class="enc-data-table">
<tr>
<th > Number:</th>
<td >1111</td>
</tr>
<tr>
<th >Plan Information:</th>
<td >1111</td>
</tr>
<tr>
<th >Date of service:</th>
<td >Today</td>
</tr>
<tr>
<th >Location Description:</th>
<td >USA</td>
</tr>
</table>
<h3>Third Heading <button class="btn btn-xs btn-success add-attribute-ctrl">ADD</button></h3>
<hr />
Do you want something like this? To set the table alignment properly I recommend setting the th and td elements width separetely!
.enc-data-table th{
width:20%
}
.enc-data-table tr{
width:80%
}
.enc-data-table {
margin: 0 0 45px 0;
width: 50%;
}
.enc-data-table th {
font-size: 12pt;
/*font-weight: 700;*/
padding: 0 5px 5px 0;
text-align: right;
}
.enc-data-table td {
font-size: 12pt;
padding: 0 0 5px 0;
}
h3 {
font-size: 20px;
}
h3 {
width: 50%;
height: 40px;
margin: 0;
padding: 0;
display: inline;
}
hr {
width: 100%
}
/*.enc-data-table th{
width:20%
}
.enc-data-table tr{
width:80%
}*/
<h3>Heading 1</h3>
<h3 style="float:right">Heading 2</h3>
<hr/>
<table class="enc-data-table" align="left">
<tr>
<th>Location:</th>
<td>A</td>
</tr>
<tr>
<th>Type:</th>
<td>B</td>
</tr>
<tr>
<th>Dates:</th>
<td>Today</td>
</tr>
<tr>
<th>Reason for visit:</th>
<td>D</td>
</tr>
</table>
<table align="right" class="enc-data-table">
<tr>
<th> Number:</th>
<td>1111</td>
</tr>
<tr>
<th>Plan Information:</th>
<td>1111</td>
</tr>
<tr>
<th>Date of service:</th>
<td>Today</td>
</tr>
<tr>
<th>Location Description:</th>
<td>USA</td>
</tr>
</table>
<h3>Third Heading <button class="btn btn-xs btn-success add-attribute-ctrl">ADD</button></h3>
<hr />
I'm trying to organize two sets of information in a particular way. I have a very crude mock-up here:
https://imgur.com/a/LrSCg
I have everything working except for the diving line between the two sets of info. I've tried setting up the entire thing as a table and then setting the appropriate border styles, but that didn't work out so well.
Here's what I currently have that gets me everything except the middle dividing line:
<table style="margin: 0 auto; border: 1px solid black; table-layout: fixed">
<tr>
<td>
<img id="left_image" class="images" alt="left_image" height="auto" width="300" style="border: 2px solid #5b5b5b">
</td>
<td style="display:block;">
<div style="float: left; margin: 20px 0 0 20px;">
<table>
<tr>
<td style="width: 75px;">Name:</td><td><span id="left_name" style="font-weight: bold"></span></td>
</tr>
<tr>
<td style="width: 75px;">Category:</td>
<td><span id="left_category" style="font-weight: bold"></span></td>
</tr>
<tr>
<td style="width: 75px;">ID:</td>
<td><span id="left_id" style="font-weight: bold;"></span></td>
</tr>
</table>
</div>
<hr>
<div style="float: right; margin: 100px 20px 0 0;">
<table>
<tr>
<td style="width: 75px;">Name:</td>
<td><span id="right_name" style="font-weight: bold"></span></td>
</tr>
<tr>
<td style="width: 75px;">Category:</td>
<td><span id="right_category" style="font-weight: bold"></span></td>
</tr>
<tr>
<td style="width: 75px;">ID:</td>
<td><span id="right_id" style="font-weight: bold"></span></td>
</tr>
</table>
</div>
</td>
<td>
<img id="right_image" class="images" alt="right_image" height="auto" width="300" style="border: 2px solid #5b5b5b">
</td>
</tr>
<tr>
<td style="text-align: center;">
<button class="btn4 btn4-confirm" onclick="selectLeftID()">Select Left</button>
</td>
<td></td>
<td style="text-align: center;">
<button class="btn4 btn4-confirm" onclick="electRightID()">Select Right</button>
</td>
</tr>
</table>
This is just experimental code, it hasn't been cleaned up yet, so please ignore all the in-line styling.
Here's a sloppy example I threw together: https://jsfiddle.net/33pc23w0/2/
I would like to make the line in code and not use any images since I'd like the elements to be flexible in size. Any suggestions on the middle lines?
Here's a quick solution. I set the main container to relative position and added two absolute position divs with appropriate borders and dimensions to handle the dividers.
.main-container {
width: 800px;
position: relative;
}
.divider-top {
position: absolute;
width: 150px;
height: 150px;
left: 300px;
border: 2px solid black;
border-left: 0px;
border-top: 0px;
}
.divider-bottom {
position: absolute;
width: 150px;
height: 167px;
top: 150px;
left: 300px;
border: 0px;
border-left: 2px solid black;
}
.details_images {
display: block;
margin: auto;
margin-top: 5px;
margin-bottom: 5px;
border-radius: 10px;
}
.btn4 {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
width: 150px;
height: 50px;
}
.btn4.focus,
.btn4:focus,
.btn4:hover {
color: #333;
text-decoration: none;
}
.btn4-confirm {
color: #fff;
background-color: #5cb85c;
border-color: #4cae4c;
}
.btn4-confirm:active {
color: #fff;
background-color: #449d44;
border-color: #398439;
}
<div class="main-container">
<div class="divider-top"></div>
<div class="divider-bottom"></div>
<table style="width: 100%; border: 1px solid black; table-layout: fixed">
<tr>
<td>
<img id="left_image" class="images" alt="left_image" height="auto" width="200" src="https://catalogue.millsarchive.org/images/generic-icons/blank.png" style="border: 2px solid #5b5b5b">
</td>
<td style="display:block;">
<div style="float: left; margin: 20px 0 0 20px;">
<table>
<tr>
<td style="width: 75px;">Name:</td>
<td><span id="left_name" style="font-weight: bold">Blah</span></td>
</tr>
<tr>
<td style="width: 75px;">Category:</td>
<td><span id="left_category" style="font-weight: bold">Blah</span></td>
</tr>
<tr>
<td style="width: 75px;">ID:</td>
<td><span id="left_id" style="font-weight: bold;">Blah</span></td>
</tr>
</table>
</div>
<div style="float: right; margin: 100px 20px 0 0;">
<table>
<tr>
<td style="width: 75px;">Name:</td>
<td><span id="right_name" style="font-weight: bold">Blah</span></td>
</tr>
<tr>
<td style="width: 75px;">Category:</td>
<td><span id="right_category" style="font-weight: bold">Blah</span></td>
</tr>
<tr>
<td style="width: 75px;">ID:</td>
<td><span id="right_id" style="font-weight: bold">Blah</span></td>
</tr>
</table>
</div>
</td>
<td>
<img id="right_image" class="images" alt="right_image" height="auto" width="200" src="https://catalogue.millsarchive.org/images/generic-icons/blank.png" style="border: 2px solid #5b5b5b">
</td>
</tr>
<tr>
<td style="text-align: center;">
<button class="btn4 btn4-confirm" onclick="selectLeftID()">Select Left</button>
</td>
<td></td>
<td style="text-align: center;">
<button class="btn4 btn4-confirm" onclick="electRightID()">Select Right</button>
</td>
</tr>
</table>
</div>
I'm running into an issue when using HTML5 form input types (number, date, email, etc) with the CSS float property. I'm trying to float these to the right, but they are not honoring that setting.
Here's a snippit where I put the CSS inline during testing:
<div class="center" style="width: 100%">
...
<div style="width: 90%" class="textfont">
...
<table style="width:100%;">
<thead>
<tr class="tableHeading">
<td style="width: 50%; text-align: center;">
Unit Types
</td>
<td style="text-align: center;">
Number of Units
</td>
</tr>
</thead>
<tbody>
<tr>
<td style="border-right: 1px;">
Single-Family Detached
</td>
<td>
<input type="number" name="txtDetached" style="width:25%; float:right" />
</td>
</tr>
<tr>
<td style="height: 32px">
Townhouse, Row, or Cluster
</td>
<td style="height: 32px">
<input type="number" name="txtCuster" style="width:25%; float:right" />
</td>
</tr>
<tr>
<td>
Garden
</td>
<td>
<input type="number" name="txtGarden" style="width:25%; float:right" />
</td>
</tr>
<tr>
<td style="height: 43px">
Mid-rise (3-5)
</td>
<td style="height: 43px">
<input type="number" name="txtMidrise" style="width:25%; float:right" />
</td>
</tr>
<tr>
<td>
High-rise (6+)
</td>
<td>
<input type="number" name="txtHighRide" style="width:25%; float: right" />
</td>
</tr>
<tr>
<td>
Other
</td>
<td>
<input type="text" name="txtOther" style="width: 80%; float: right;" />
</td>
</tr>
</tbody>
</table>
...
</div>
...
</div>
Yes, I know tables are frowned upon...
Here's the overall CSS:
.Header
{
font-size: 30px;
font-family: Cambria;
color: White;
background: #254117;
text-align: center;
font-weight: bold;
width: 90%;
}
.subHeading
{
font-family: Arial;
font-size: 11px;
text-align: left;
}
.container
{
display: table;
width: 90%;
border-collapse: collapse;
}
.heading
{
font-weight: bold;
display: table-row;
background-color: #C91622;
text-align: center;
line-height: 25px;
font-size: 14px;
font-family: georgia;
color: #fff;
}
.table-row
{
display: table-row;
text-align: center;
}
.col
{
display: table-cell;
border: 1px solid #CCC;
}
.tableHeading
{
font-family: Arial;
background: #99C68E;
font-size: 18px;
text-align: left;
}
.textfont
{
font-size: 15px;
font-family: Arial;
text-align: left;
}
input[type=text]
{
width: 100%;
height: 22px;
}
textarea
{
width: 98%;
}
table
{
border-collapse: collapse;
border: 1px solid black;
border-spacing: 10px;
}
tr
{
border-collapse: collapse;
border: 1px solid black;
}
td, th
{
padding: 5px;
}
.center
{
margin-left: auto;
margin-right: auto;
}
Here's what this displays:
As you can see the input element with type="text" works without an issue, however when type="number" it remains at the default, left justified.
This behavior exists in IE 10, FireFox, and Chrome.
I discovered the workaround is to wrap the HTML5 input types in a div and then set the CSS to float the div right, and then this works without issue. I had issues finding information for this on the net, but is this a known issue? Is the workaround actually the proper way of handling this?
EDIT: Added full CSS (minus stuff I moved inline for testing). Added entire table and the div's they are wrapped in. If I copy all of this to jsFiddle it works properly, so I'm obviously doing something wrong here...
OK, the problem related to floating elements inside <td>, use text-align can fix it.
<td style="text-align:right;">
...
</td>
More can be read here DIV in <td> float right
I tried tr:nth element ... not working
Below is my jsp and css
jsp fetches 2 lists from java class
Includes a validation if list is empty and then displays values
data-grid is table class
<table class="data-grid" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th colspan="6">Excesses to be actioned</th>
</tr>
</thead>
<tr class="header">
<th>Excess ID</th>
<th>Date</th>
<th>Client</th>
<th>Product</th>
<th>Amount</th>
<th>DA</th>
</tr>
<tbody id="tbNa">
<c:choose>
<c:when
test="${empty actionBean.excessList.newActiveCustomerExcessUIList}">
<tr>
<td colspan="6" align="center"><font color="red">No
data available for Active Excess List</font></td>
</tr>
</c:when>
<c:otherwise>
<c:forEach
items="${actionBean.excessList.newActiveCustomerExcessUIList}"
var="customerExcess" varStatus="loop">
<c:set var="clientName" value="${customerExcess.clientName}"
scope="page"></c:set>
<c:set var="ultimateParent"
value="${customerExcess.ultimateParent}" scope="page"></c:set>
<c:set var="cif" value="${customerExcess.cif}" scope="page"></c:set>
<c:forEach items="${customerExcess.excessList}" var="excess">
<tr>
<td><c:out value="${excess.excessId }"></c:out></td>
<td><c:out value="${excess.openDate }"></c:out></td>
<td><a href="#" onclick="openClientExcessPage('${cif}');"><c:out
value="${clientName}"></c:out></a></td>
<td><c:out value="${ultimateParent}"></c:out></td>
<td><c:out value="${excess.excessAmount }"></c:out></td>
<td><c:out value="${excess.excessDa}"></c:out></td>
</tr>
</c:forEach>
</c:forEach>
</c:otherwise>
</c:choose>
<c:choose>
<c:when
test="${empty actionBean.excessList.approvedCustomerExcessUIList}">
<tr>
<td colspan="6" align="center"><font color="red">No
data available for Approved Excess List</font></td>
</tr>
</c:when>
<c:otherwise>
<c:forEach
items="${actionBean.excessList.approvedCustomerExcessUIList}"
var="customerExcess">
<c:set var="clientName" value="${customerExcess.clientName}"
scope="page"></c:set>
<c:set var="ultimateParent"
value="${customerExcess.ultimateParent}" scope="page"></c:set>
<c:forEach items="${customerExcess.excessList}" var="excess">
<tr>
<td><c:out value="${excess.excessId }"></c:out></td>
<td><c:out value="${excess.openDate }"></c:out></td>
<td><a href="#" onclick="openClientExcessPage('${cif}');"><c:out
value="${clientName}"></c:out></a></td>
<td><c:out value="${ultimateParent}"></c:out></td>
<td><c:out value="${excess.excessAmount }"></c:out></td>
<td><c:out value="${excess.excessDa }"></c:out></td>
</tr>
</c:forEach>
</c:forEach>
</c:otherwise>
</c:choose>
</tbody>
</table>
Data-grid is table class...below is the css written for the table
I don't want to change row color..I need to change font color of the data in the even rows
.data-grid {
margin: 0px;
padding: 0px;
width : 60%;
height : 40%;
padding-top: 10%;
padding-left: 15%;
white-space: nowrap;
}
.data-grid select {
padding: 3px 0px;
border: 1px solid #DCDCDC;
}
.data-grid td {
font-size: 11px;
color: #000000;
background-color: white;
border: 0px;
border-left: 1px;
border-bottom: 1px;
border-style: solid;
border-color: #DBE5F1;
padding: 5px;
}
.data-grid thead {
color: #004080;
font-size: 12px;
font-weight: normal;
border-color: #FFF;
vertical-align: text-top;
background-color: #C3C3C3;
height: 20px;
padding: 2px 5px;
}
.data-grid .header th {
color: #002577;
font-size: 11px;
font-weight: bold;
border-color: #FFF;
text-align: center;
vertical-align: text-top;
background-color: #D5E0E6;
}
.data-grid tr:nth-child(even) {color: #CCC}
.data-grid tr:nth-child(odd) {color: #FFF}
Check this example
<!DOCTYPE html>
<html>
<head>
<style>
.myclass1 tr:nth-child(odd)
{
background:#ff0000;
}
.myclass1 tr:nth-child(even)
{
background:#0000ff;
}
.myclass2 tr:nth-child(odd)
{
background:#00ff00;
}
.myclass2 tr:nth-child(even)
{
background:#ff0000;
}
</style>
</head>
<body>
<table width="100%" border=1 class="myclass1">
<tr><td>aaaa</td></tr>
<tr><td>bbbb</td></tr>
<tr><td>cccc</td></tr>
<tr><td>dddd</td></tr>
</table>
<table width="100%" border=1 class="myclass2">
<tr><td>aaaa</td></tr>
<tr><td>bbbb</td></tr>
<tr><td>cccc</td></tr>
<tr><td>dddd</td></tr>
</table>
</body>
</html>
tr:nth-child(even) {background-color: #f2f2f2;color:red}
tr:nth-child(odd) {background-color: #f2f2f2;color:blue}
Here is the JSFiddle