I have a table inside of div and I am trying to set the width so that the columns on the output fill the whole div with id left.
Here is all the code and along with jsfiddle : https://jsfiddle.net/qsogubjd/
#sortPanel {
width: 565px;
height: 165px;
margin: 10px 15px;
display: block;
border: 0px solid #fff;
}
#sortPanel td {
height: 165px;
width: 11px;
overflow: hidden;
display: inline-block;
white-space: nowrap;
padding: 0;
position: relative;
}
.cc {
display: block;
width: 5px;
position: absolute;
bottom: 0px;
background-color: #999;
border-top: 4px solid #fff;
margin: 0px;
margin-top: 4px;
}
.ccH1 {
display: block;
width: 5px;
background-color: #F22613;
margin: 0px;
position: absolute;
bottom: 0px;
}
.ccH2 {
display: block;
width: 5px;
background-color: #F2B705;
margin: 0px;
position: absolute;
bottom: 0px;
}
#left {
width: 590px;
height: 190px;
margin: 10px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 3px #000;
-moz-box-shadow: 0 1px 3px #000;
border-top: 1px solid #555;
box-shadow: 0 1px 3px #000;
background: -webkit-linear-gradient(#444, #333);
background: -moz-linear-gradient(#444, #333);
background: -o-linear-gradient(#444, #333);
background: -ms-linear-gradient(#444, #333);
background: linear-gradient(#444, #333);
position: relative;
float: left;
}
<div id="left">
<table id="sortPanel">
<tr>
<td id="b0">
<div class="cc" style="height: 144px;"></div>
</td>
<td id="b1">
<div class="cc" style="height: 35px;"></div>
</td>
<td id="b2">
<div class="cc" style="height: 6px;"></div>
</td>
<td id="b3">
<div class="cc" style="height: 64px;"></div>
</td>
<td id="b4">
<div class="cc" style="height: 12px;"></div>
</td>
<td id="b5">
<div class="cc" style="height: 153px;"></div>
</td>
<td id="b6">
<div class="cc" style="height: 70px;"></div>
</td>
<td id="b7">
<div class="cc" style="height: 137px;"></div>
</td>
<td id="b8">
<div class="cc" style="height: 19px;"></div>
</td>
<td id="b9">
<div class="cc" style="height: 131px;"></div>
</td>
</tr>
</table>
</div>
So far I tried putting position: relative; on selectors, it didn't work. Then I tried display: block;, it didn't work either.
To make reading code easier:
The width attribute of td defines the seperation between the columns in the html output. Increasing the value of width will set columns further for each other, spreading them.
While width of div inside of td sets the width of column itself. Increasing this value will make colums thicker.
As far as I researched the solution should include %: width: someValue%.
How can I change the css code in order to spead the columns across the div with id "left" and make the whole table responsive?
The following caused the issue:
table#sortPanel has a display: block;
td.cc has a display: block;
table has a defined width (565px)
td has a defined width (5px)
td's naturally expand to occupy full width of the table without the need of any css.
When td's are given display: block, they loose this natural property.
Just remove these styles and td's will occupy full span of the table.
Give table a width: 100% and it'll occupy the full span of div#left.
Here is your code with modifications:
<div id="left">
<table id="sortPanel">
<tr>
<td id="b0">
<div class="cc" style="height: 144px;"></div>
</td>
<td id="b1">
<div class="cc" style="height: 35px;"></div>
</td>
<td id="b2">
<div class="cc" style="height: 6px;"></div>
</td>
<td id="b3">
<div class="cc" style="height: 64px;"></div>
</td>
<td id="b4">
<div class="cc" style="height: 12px;"></div>
</td>
<td id="b5">
<div class="cc" style="height: 153px;"></div>
</td>
<td id="b6">
<div class="cc" style="height: 70px;"></div>
</td>
<td id="b7">
<div class="cc" style="height: 137px;"></div>
</td>
<td id="b8">
<div class="cc" style="height: 19px;"></div>
</td>
<td id="b9">
<div class="cc" style="height: 131px;"></div>
</td>
</tr>
</table>
</div>
#sortPanel {
//width: 565px;
width: 100%;
height: 165px;
margin: 10px 0x;
//display: block;
display: table;
border: 0px solid #fff;
}
#sortPanel td {
height: 165px;
//width: 11px;
overflow: hidden;
//display: inline-block;
white-space: nowrap;
padding: 0;
position: relative;
vertical-align: bottom;
}
.cc {
display: block;
//width: 5px;
width: 100%;
//position: absolute;
bottom: 0px;
background-color: #999;
border-top: 4px solid #fff;
margin: 0px;
margin-top: 4px;
}
.ccH1 {
display: block;
width: 5px;
background-color: #F22613;
margin: 0px;
position: absolute;
bottom: 0px;
}
.ccH2 {
display: block;
width: 5px;
background-color: #F2B705;
margin: 0px;
position: absolute;
bottom: 0px;
}
#left {
width: 590px;
//height: 190px;
margin: 10px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 3px #000;
-moz-box-shadow: 0 1px 3px #000;
border-top: 1px solid #555;
box-shadow: 0 1px 3px #000;
background: -webkit-linear-gradient(#444, #333);
background: -moz-linear-gradient(#444, #333);
background: -o-linear-gradient(#444, #333);
background: -ms-linear-gradient(#444, #333);
background: linear-gradient(#444, #333);
position: relative;
float: left;
}
https://jsfiddle.net/cpr4ztvj/
You have to delete some of the unnecessary attribute value pairs specifically related to display and position, those are very important in css, be sure to read up on them. I added the changes in the comments of css code and also I will share fiddle link to check the responsiveness https://jsfiddle.net/nukjh6ea/, now you may add up td s as you want.
#sortPanelA, sortPanelB {
width: 100%;/* occupy the whole width of div left */
height: 165px;
margin: 10px 15px;
border: 0px solid #fff;
}
#sortPanelA td, sortPanelB td {
height: 165px;
overflow: hidden;
white-space: nowrap;
padding: 0;
position: relative;
}
.cc {
display: block;
width: 50%;/* the width of column, you may play around with it */
position: absolute;
bottom: 0px;
background-color: #999;
border-top: 4px solid #fff;
margin: 0px;
margin-top: 4px;
}
.ccH1 {
display: block;
width: 5px;
background-color: #F22613;
margin: 0px;
position: absolute;
bottom: 0px;
}
.ccH2 {
display: block;
width: 5px;
background-color: #F2B705;
margin: 0px;
position: absolute;
bottom: 0px;
}
#left {
width: 90%;/* take up the 90% of body */
height: 190px;
margin: 10px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 3px #000;
-moz-box-shadow: 0 1px 3px #000;
border-top: 1px solid #555;
box-shadow: 0 1px 3px #000;
background: -webkit-linear-gradient(#444, #333);
background: -moz-linear-gradient(#444, #333);
background: -o-linear-gradient(#444, #333);
background: -ms-linear-gradient(#444, #333);
background: linear-gradient(#444, #333);
position: relative;
float: left;
}
<div id="left">
<table id="sortPanelA">
<tr>
<td id="b0">
<div class="cc" style="height: 144px;"></div>
</td>
<td id="b1">
<div class="cc" style="height: 35px;"></div>
</td>
<td id="b2">
<div class="cc" style="height: 6px;"></div>
</td>
<td id="b3">
<div class="cc" style="height: 64px;"></div>
</td>
<td id="b4">
<div class="cc" style="height: 12px;"></div>
</td>
<td id="b5">
<div class="cc" style="height: 153px;"></div>
</td>
<td id="b6">
<div class="cc" style="height: 70px;"></div>
</td>
<td id="b7">
<div class="cc" style="height: 137px;"></div>
</td>
<td id="b8">
<div class="cc" style="height: 19px;"></div>
</td>
<td id="b9">
<div class="cc" style="height: 131px;"></div>
</td>
</tr>
</table>
</div>
Change .cc {width: 100%} and #sortPanelA td {width: 3.5rem}
EDIT
To make whole table responsive here are steps:
change div, table and tbody width to 100%
set table display: table
remove td width
set div.cc to 100%
set , not with css
Here is the code in fiddle: https://jsfiddle.net/meshin/uuL2f43g/
You're mixing and matching different block models without understanding what they do. A table block model is pretty responsive by default and by adding blocks and inline-blocks to things you're complicating matters.
Remove all the display: block and display: inline-block from your table elements. Then set the .cc div to 100% width of the table cell. Your table will then scale to whatever you need. If you want it 100% set the table to 100%.
See example:
https://jsfiddle.net/mede6n8j/
Steps to fix:
Remove display: block; from #sortPanelA, sortPanelB
Remove display: block and display:inline-block; from #sortPanelA td, sortPanelB td
Remove width: 11px; from #sortPanelA td, sortPanelB td
Change width: 5px; to width: 100% on .cc. This will make the divs scale to the table-cells
I would recommend you to first try making the table width 100% , It should work.
In case if it does not work then since you have 9 td's in a row try setting the td with to 11.11%. But if you have n number of td then it will not work.
Regards,
Vinit Patil.
Related
The issue is that I have a div list of ott-col-right-inner but when I tried to add the table under id the border in that div goes through. here is it's css:
.point-count:before {
content: '';
position: absolute;
border-bottom: none;
left: 48px;
border-left: solid 4px #F3F3F3;
height: 100%;
top: 30px;
}
I only want the border to stop in the point-count div
Here is the JSfiddle link:
https://jsfiddle.net/q6pmaebj/
code in question:
<div class="ott-col-right-inner">
<div class="point-count"><h3>01</h3></div>
<div class="point-text"><p>Step 1</p></div>
</div>
<div class="ott-col-right-inner">
<div class="point-count"><h3>02</h3></div>
<div class="point-text"><p>Step 2</p></div>
</div>
<div class="ac">
<table style="width: 100%; border-collapse: collapse; table-layout: fixed; border: 1px solid #99acc2;">
<tbody>
<tr>
<td style="border: 0.5pt solid #000000; width: 100%; padding: 4px;">
<p>One</p>
</td>
</tr>
<tr>
<td style="border: 0.5pt solid #000000; width: 100%; padding: 4px;">
<p>Two</p>
</td>
</tr>
</tbody>
</table>
</div>
I tried to do something with nth-last child where I take the border out in the last bit, but this seems to be not working:
.point-count:last-child:before { border-left: none; }
Note: I cannot change the div tags because this is in a for each loop
After looking through the jsfiddle link it looks like the solution is that the ott-col-right div tag wasn't closed and by adding that we were able to take the styling and only apply it to what is enclosed in the tag. I'm learning myself so let me know if this works for you!
Screenshot from jsfiddle with the closing tag
add this css
.point-count:before {
content: '';
position: absolute;
border-bottom: none;
left: 35px; //change here
border-left: solid 4px #F3F3F3;
height: 100%;
top: -30px; //change here
}
.ott-col-right-inner{
position: relative;
}
.ott-col-right-inner:first-child .point-count:before{
top: 10px;
}
fiddle here
it's not border, it's the child's before and you set its height to 100%, so that's why. you need to manage its height properly. here I set it only 200px
.ott-col-right {
flex: 0 0 50%;
max-width: 50%;
position: relative;
overflow: hidden;
margin-bottom: 20px;
padding-right: 15px;
padding-left: 15px;
}
.point-count {
margin: 0px;
float: left;
width: 70px ;
height: 70px ;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: #F3F3F3;
}
.point-count h3 {
z-index: 1;
color: #3E3E3E;
font-size: 23px;
font-weight: 600;
}
.point-text {
text-align: left;
float: left;
width: calc(100% - 100px);
height: 70px;
display: flex;
align-items: center;
margin: 0px auto;
margin-left: 20px;
}
.ott-col-right-inner {
width: 100%;
display: block;
float: left;
padding: 10px 0px;
}
.point-text p {
font-family: "Exo 2", sans-serif;
color: #828389;
font-size: 16px;
margin: 0px 5px;
}
.point-text p a {
color: #CE1126;
font-size: 15px;
font-weight: 700;
position: relative;
}
.point-count:nth-child(1):before {
content: '';
position: absolute;
border-bottom: none;
left: 48px;
border-left: solid 4px #F3F3F3;
height: 200px;
top: 30px;
}
.ott-col-right-inner:last-child {
padding-bottom: 0px;
}
.vidyard-player-container
{
border-radius: 20px;
}
<div class="ott-col-right">
<div class="ott-col-right-inner">
<div class="point-count"><h3>01</h3></div>
<div class="point-text"><p>Step 1</p></div>
</div>
<div class="ott-col-right-inner">
<div class="point-count"><h3>02</h3></div>
<div class="point-text"><p>Step 2</p></div>
</div>
<div class="ott-col-right-inner">
<div class="point-count"><h3>03</h3></div>
<div class="point-text"><p>Step 3</p></div>
</div>
<div class="ac">
<table style="width: 100%; border-collapse: collapse; table-layout: fixed; border: 1px solid #99acc2;">
<tbody>
<tr>
<td style="border: 0.5pt solid #000000; width: 100%; padding: 4px;">
<p>One</p>
</td>
</tr>
<tr>
<td style="border: 0.5pt solid #000000; width: 100%; padding: 4px;">
<p>Two</p>
</td>
</tr>
</tbody>
</table>
</div>
I am building a custom chips control and facing a problem in aligning a close div to the right and middle. Can someone help please. I want to align the close button vertically middle if the text wraps to multiple lines
<div class="chips-container">
<div *ngFor="let item of items; let i = index" class="chips">
<div class="chip-text">{{ item }}</div>
<div class="chip-close">x</div>
</div>
<input
class="input-chips"
(keyup.enter)="add($event)"
(keyup)="autogrow($event)"
style="width: 15px"
/>
</div>
My Style
.chips-container {
border: 1px solid gray;
height: auto;
min-height: 30px;
width: 230px;
position: relative;
}
.chips {
background-color: rgb(236, 236, 236);
border: 1px solid rgb(124, 124, 124);
border-radius: 14px;
margin: 3px;
padding-left: 3px;
height: auto;
display: inline-block;
}
.chip-text {
display: inline-block;
vertical-align: middle;
word-wrap: break-word;
}
.chip-close {
background-color: rgb(204, 204, 204);
height: 20px;
width: 20px;
border-radius: 50%;
//display: inline-block;
text-align: center;
margin-left: 2px;
float: right;
}
I replaced my Divs with table layout and it looks good, however, my input text control aligns in the bottom
<div class="chips-container">
<table
*ngFor="let item of pgFilters[i].value; let i = index"
class="chips"
>
<tr>
<td class="chip-text">{{ item }}</td>
<td><div class="chip-close">x</div></td>
</tr>
</table>
<input
style="width: 15px"
/>
</div>
Use positioning, put relative position on the parent element, in your case: .chips, and then relative position on the .chip-close, and then position it as you wish. Btw also added padding-right on the text itself, just so the word wouldn't overlap with the x icon.
.chips-container {
border: 1px solid gray;
height: auto;
min-height: 30px;
width: 230px;
position: relative;
}
.chips {
background-color: rgb(236, 236, 236);
border: 1px solid rgb(124, 124, 124);
border-radius: 14px;
margin: 3px;
padding-left: 3px;
height: auto;
position: relative;
}
.chip-text {
display: inline-block;
word-wrap: break-word;
padding-right: 20px;
}
.chip-close {
background-color: rgb(204, 204, 204);
height: 20px;
width: 20px;
border-radius: 50%;
text-align: center;
position: absolute;
top: 50%;
right: 2px;
transform: translateY(-50%);
}
<div class="chips-container">
<div *ngFor="let item of items; let i = index" class="chips">
<div class="chip-text">this is just a test tjak jldskfds lsdjkf kjdf eljf lsadjfoi lajkdfoasdfkj </div>
<div class="chip-close">x</div>
</div>
<input
class="input-chips"
(keyup.enter)="add($event)"
(keyup)="autogrow($event)"
style="width: 15px"
/>
</div>
I am trying to vertically align a div (the "p" element in this example but it could be anything a div a link, an image, etc.) which needs to have its position property set to absolute. I followed this example: http://davidwalsh.name/table-cell-position-absolute
But I can get it to work. Here is the code:
<div style="width: 400px; height: 48px; background-color: #EEE; margin: 0 auto;">
<div style="display: table; position: relative; border: 1px solid blue; width: 100%; height: 100%;">
<div style="display: table-cell; border: 2px solid green;">
<div style="position:relative; overflow: auto; height: 100%;">
<p style="position:absolute; bottom:0; right:0; font-size: 18px; color: black; border: 1px solid orange;">VERTICALLY CENTER ME PLEASE!</p>
</div>
</div>
</div>
</div>
And the jsfiddle: http://jsfiddle.net/bqm7wudc/2/
Could someone suggest a solution please?
I actually sorted the problem that way:
<div style="display: table; position: relative; border: 1px solid red; width: 960; height: 48px; margin: 0 auto;">
<ul style="display: table; vertical-align: middle; border: 1px solid orange; padding: 0px; position:absolute; left: 700px; margin: 0; height: 100%;">
<li style="display: table-cell; vertical-align: middle; font-size: 20px; font-weight: 900; padding-right: 20px;">toto</li>
<li style="display: table-cell; vertical-align: middle; font-size: 20px; font-weight: 900; padding-right: 20px;">titi</li>
</ul>
</div>
The text is defined as the content of a list. The ul element is itself a table (positioned using the absolute mode), while the li elements are table cells. This seems to work.
Updated fiddle: http://jsfiddle.net/bqm7wudc/7/
I have an HTML page in which there is a table which populates data from a database table and I am trying to restrict the size of the table by placing it in a div like in the following
<div id="scrollablebody">
<table class="clientTable">
<thead>
<tr>
<th>Grade</th>
<th>Term</th>
<th colspan="3">Actions</th>
</tr>
</thead>
<!--ko foreach: products-->
<tr>
<td class="clientproductHeader" data-bind="text: $data">
</td>
<td class="clientproductHeader" colspan="13"></td>
</tr>
<tbody data-bind="foreach: ko.observableArray($root.datainput()).extendsdistinct('Product').index.Product()[$data]">
<tr data-bind="template: { name: $root.displayMode, data: $data }"></tr>
</tbody>
<!--/ko-->
</table>
</div>
CSS for div
#scrollablebody{height:500px;overflow-y:auto;width:100%;}
But for some reasons the text in tbody is occupying all the space like in the following image
As you can see in the above picture the row with c5+ is unusually occupying lot of space
CSS for the Table
.clientTable {
max-width: 100%;
background-color: grey;
height:75%;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px;
width: 98%;
margin-left:0;
margin-right:100px;
float: left;
overflow:scroll;
}
table.clientTable thead tr .header {
background-image: url(images/bg.png);
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
table.clientTable td {
padding: 1px;
line-height: 10px;
text-align: center;
/*background-color:#3C78B5;*/
vertical-align: auto;
border: 1px solid #0088cc;
width: 120px;
}
.clientTable th {
padding: initial;
line-height: normal;
text-align: center;
width: initial;
height: 20px;
border: 1px outset gray;
background-color: black;
color: white;
cursor: pointer;
}
Change height to max-height. It's going grow to size if you don't specify and have the overflow as auto.
Is it possible to have a vertical float working by analogy with the horizontal one? In the Html below I'd like the green button to be as it is and the yellow to float to the bottom beyond gray shape edge.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table style="margin: 250px; width:50px; height: 100px; background-color: #ccc; table-layout: fixed;">
<tr>
<td style="vertical-align:top;">
<div style="margin-top:-20px; width:50px; height: 40px; background-color: Green;">Top</div>
<div style="margin-bottom:-20px; width:50px; height: 40px; background-color: Yellow;">Bottom</div>
</td>
</tr>
</table>
</body>
</html>
Update 1 - here's a bit closer to realm picture of what I'm trying to achieve. I'm looking for a vertical uniform panel, i.e. the distance between its children should be the same. I managed to do it with the horizontal layout, but got stuck to the vertical implementation.
Html:
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table style="margin: 250px; width:70px; height: 400px; background-color: #ccc; table-layout: fixed;">
<tr>
<td style="vertical-align: middle; background-color: Gray; padding: 5px;">
<!-- <div style="margin-top:-20px; width:50px; height: 40px; background-color: Green;">1</div>-->
<div style="margin: -20px auto auto auto; width:50px; height: 40px; background-color: white;">Top!!!</div>
<div style="margin: auto auto -20px auto; width:50px; height: 40px; background-color: white;">2</div>
</td>
</tr>
<tr>
<td style="vertical-align: middle; background-color: Gray; padding: 5px;">
<div style="margin: auto auto -20px auto; width:50px; height: 40px; background-color: white;">3</div>
</td>
</tr>
<tr>
<td style="vertical-align: middle; background-color: Gray; padding: 5px;">
<div style="margin: auto auto -20px auto; width:50px; height: 40px; background-color: white;">4</div>
</td>
</tr>
<tr>
<td style="vertical-align: middle; background-color: Gray; padding: 5px;">
<div style="margin: auto auto -20px auto; width:50px; height: 40px; background-color: white;">5</div>
</td>
</tr>
</table>
</body>
</html>
If they don't always have to be in top-down 1st-to-last order did you try simple inline-blocks? That should allow them to fill out horizontally and then wrap vertically when not enough space.
.columns .icon { display: inline-block; width: 80px; height: 80px; background-color: lightblue; margin: 10px }
http://jsfiddle.net/JT3La/
using relative position and and set the bottom as the negative of the box height
http://jsfiddle.net/e9uet/