I created table with ul lists and styled as table with CSS display:table
The problem is that my table rows should be draggable and grouped in some parts which affects on list behavior like table. Here is my Code http://jsfiddle.net/frontDev111/38pvx9bn/1/
So In my code dd-list is table, dd-itemis table-row and dd-handle is table-cell. It works fine when I have only one table, but I need to have nested tables to make some part of row draggable (e.g from 1.draggable entire row, 2.draggable only right part of row) . So I set dd-list in dd-list in each row. This affects on behavior like table, and table-cell become independent from each other.
So, what can you advise to get table in table but keep table-cell's dependence from each other?
.dd-list {
display: table ;
vertical-align: middle;
width: 100%;
margin: 0 auto;
padding: 0;
}
.dd-item {
list-style: decimal;
display: table-row ;
vertical-align: middle;
}
.dd-item, .dd-empty, .dd-placeholder {
position: relative ;
padding: 0;
margin: 0;
min-height: 20px ;
}
.dd-handle {
display: table-cell ;
vertical-align: top;
margin: 5px 0 ;
padding: 10px;
text-decoration: none ;
font-weight: bold ;
border-bottom: 1px solid #dddddd;
border-right: 1px solid #dddddd;
box-sizing: border-box;
}
.dd-container, .btn-gray {
border-left: 1px solid #dddddd;
}
<ol ui-tree-nodes="" class="dd-list dd-container ng-scope">
<li class="dd-item">
<div class="dd-handle dd-head">-</div>
<div class="dd-handle dd-head">1.draggable dfdfd</div>
<ol class="dd-list">
<li class="dd-item">
<div class="dd-handle dd-head">2.draggable</div>
<div class="dd-handle dd-head">bbb</div>
<div class="dd-handle dd-head">ccc</div>
<div class="dd-handle dd-head">ddd</div>
<div class="dd-handle dd-head">gg</div>
<div class="dd-handle dd-head">ggg</div>
</li>
</ol>
</li>
<li class="dd-item ng-pristine ng-untouched ng-valid ng-scope angular-ui-tree-nodes" ng-repeat="employee in employees" ui-tree-nodes="" ng-model="employees" data-type="employee">
<div class="dd-handle ng-binding">1</div>
<div class="dd-handle">
<edit-in-place id="1" value="employee.name" class="ng-isolate-scope edit-in-place"><span ng-click="edit()" ng-bind="value" class="ng-binding">test</span>
</edit-in-place>
</div>
<ol class="dd-list ng-pristine ng-untouched ng-valid ng-scope angular-ui-tree-nodes" ui-tree-nodes="" ng-model="employee.contracts" data-type="contract">
<li class="dd-item ng-scope angular-ui-tree-node" ng-repeat="contract in employee.contracts" ui-tree-node="" collapsed="false">
<div class="dd-handle">
<edit-in-place value="contract.client_name" class="ng-isolate-scope edit-in-place"><span ng-click="edit()" ng-bind="value" class="ng-binding">fghfghfghfgh</span>
</edit-in-place>
</div>
<div class="dd-handle"> sdfsdgdfg</div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
</li>
<li class="dd-item ng-scope angular-ui-tree-node" ng-repeat="contract in employee.contracts" ui-tree-node="" collapsed="false">
<div class="dd-handle">
<edit-in-place value="contract.client_name" class="ng-isolate-scope edit-in-place"><span ng-click="edit()" ng-bind="value" class="ng-binding">test</span>
</edit-in-place>
</div>
<div class="dd-handle"> sdfsdgdfg</div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
<div class="dd-handle"> </div>
</li>
</ol>
</li>
</ol>
Please have a look at the following markup:
<div class="wrapper">
<article class="main" >My awesome content here </article>
<footer class="footer">Some informations here </footer>
<header class="header">My site title goes here </header>
<aside class="sidebar">Here is my side content </aside>
<aside class="annexe" >Some more side content </aside>
</div>
Now the CSS. Pay attention to the number of lines:
.wrapper {
display: grid;
grid-columns: 200px 15px 1fr 15px 100px;
grid-rows: (auto 15px)[2] auto;
}
.header, .footer { grid-column-span: 5; }
.sidebar,
.main,
.annexe { grid-row: 3; }
.header { grid-row: 1; }
.footer { grid-row: 5; }
.sidebar { grid-column: 1; }
.main { grid-column: 3; }
.annexe { grid-column: 5; }
Done. 10 lines. No float. No inline-block. No height. No width. No margin. And if you want to make everything nice on small devices.
Note: I won’t explain the syntax. If you want to understand how works the Grid Layout, please have a look at: CSS-Tricks
Related
I have a code pen at https://codepen.io/james-hudson3010/pen/wveJqXd
What I am looking to achieve is the following:
I have an arbitrary number of cells. This example only uses 10, but it could be more or less than 10
Each cell has a footer which needs to be aligned to the bottom of cell so that they are aligned across cells in the same row
The height of a cell can vary, but the height needs to be stretched so every cell in the same row has the same height to support #2
This almost works perfectly using Safari ( Version 14.1.2 (15611.3.10.1.5, 15611) ), but the last cell in the last row is wider than it should be.
The behavior is worse in Chrome ( Version 93.0.4577.63 (Official Build) (x86_64) ). The rows are drawn higher than they should be. The last cell in the last row is to wide.
Is this due to a lack of complete browser support?
If this is due to not specifying my css correctly, what do I need to do?
.example1 {
display: grid;
grid-template-columns: repeat(auto-fill, 300px);
align-items: stretch;
}
div {
border: solid 1px;
padding: 1rem;
}
.contentdiv {
background-color: red;
display: table;
height: 100%;
width: 100%;
}
.foot {
display: table-row;
vertical-align: bottom;
height: 1px;
}
<div class="example1">
<div class="contentdiv">1<br/>a<br/>a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">2
<div class="foot">bottom</div>
</div>
<div class="contentdiv">3
<div class="foot">bottom</div>
</div>
<div class="contentdiv">4
<div class="foot">bottom</div>
</div>
<div class="contentdiv">5a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">6
<div class="foot">bottom</div>
</div>
<div class="contentdiv">7a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">8
<div class="foot">bottom</div>
</div>
<div class="contentdiv">9
<div class="foot">bottom</div>
</div>
<div class="contentdiv">10a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
</div>
This has to do with the setting the display to table for the contentdiv - and setting it's width and height to 100%.
Basically what is happening - if you view your elements in the web inspector - you'll see that all of your elements are wider than 300px because of the padding 1rem, so they are actually overlapping already, you just can't visually see it until the last row.
You can avoid this setting, * { box-sizing: border-box } and the display to flex instead, and using the justify-content property to keep the foot aligned on all rows:
* {
box-sizing: border-box;
}
.example1 {
display: grid;
grid-template-columns: repeat(auto-fill, 300px);
align-items: stretch;
}
div {
border: solid 1px;
padding: 1rem;
}
.contentdiv {
background-color: red;
display: flex;
flex-direction: column;
justify-content: space-between;
/* Avoid the borders stacking */
margin: -1px;
}
<div class="example1">
<div class="contentdiv">1<br/>a<br/>a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">2
<div class="foot">bottom</div>
</div>
<div class="contentdiv">3
<div class="foot">bottom</div>
</div>
<div class="contentdiv">4
<div class="foot">bottom</div>
</div>
<div class="contentdiv">5a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">6
<div class="foot">bottom</div>
</div>
<div class="contentdiv">7a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">8
<div class="foot">bottom</div>
</div>
<div class="contentdiv">9
<div class="foot">bottom</div>
</div>
<div class="contentdiv">10a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
</div>
From my comment,
display:table is not a good idea here (table-layout:fixed would be required for the width) and height : 1px (expanded cause of the table-layout display) is also not a good idea, while flex or grid will do this without sides effects minus the box-sizing:border-box missing to mind height:100% and padding/ border.To set that element at the bottom, flex or grid should be the way to IMHO
here is an example with grid instead table for display ;)
.example1 {
display: grid;
grid-template-columns: repeat(auto-fill, 300px);
align-items: stretch;
}
div {
border: solid 1px;
padding: 1rem;
box-sizing:border-box;
}
.contentdiv {
background-color: red;
display: grid;
height: 100%;
}
.foot {
margin-top:auto;/* push it all the way down */
}
<div class="example1">
<div class="contentdiv">1<br/>a<br/>a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">2
<div class="foot">bottom</div>
</div>
<div class="contentdiv">3
<div class="foot">bottom</div>
</div>
<div class="contentdiv">4
<div class="foot">bottom</div>
</div>
<div class="contentdiv">5a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">6
<div class="foot">bottom</div>
</div>
<div class="contentdiv">7a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
<div class="contentdiv">8
<div class="foot">bottom</div>
</div>
<div class="contentdiv">9
<div class="foot">bottom</div>
</div>
<div class="contentdiv">10a<br/>a<br/>a<br/>
<div class="foot">bottom</div>
</div>
</div>
Not clear about the requirement you have put in ,if you are expecting this ()
Also you can better play around with flex property which is easier
grid image sample
if so I just changed the height in class contentdiv to inherit.
For example - I have an ordered list <ol> with 7 <li> items in it and each one of them contains some <div></div> containers and one of them is <div class="title"></div>. And when resizing screen in one of the <li> items title container breaks and makes 2 lines. Is it possible to expand all other <div class="title"></div> that in all li items that container still matches in height?
I mean using just css, without javascript
In pictures - Current result -
Expected result -
Thank you a lot for any advice! :)
able with grid.
.box {
width:360px;
display:grid;
grid-template-columns:100px 100px 100px;
grid-gap:20px;
grid-auto-rows:30px;
background:#f0f0f0;
padding:10px;
}
.price1, .price2, .price3 {
font-weight:bold;
}
<div class="box">
<div class="text1">asdasd asdasda sad as asd</div>
<div class="text2">asdasd asd</div>
<div class="text3"> asdasd asd </div>
<div class="price1">$58.00</div>
<div class="price2">$58.00</div>
<div class="price3">$58.00</div>
</div>
Please find below code:
var maxHeight = -1;
$('.product-item').each(function() {
if ($(this).find('.product-item-brand').height() > maxHeight) {
maxHeight = $(this).find('.product-item-brand').height();
}
});
$('.product-item-brand').height(maxHeight);
var maxHeight1 = -1;
$('.product-item').each(function() {
if ($(this).find('.product-item-link').height() > maxHeight) {
maxHeight = $(this).find('.product-item-link').height();
}
});
$('.product-item-link').height(maxHeight);
jQuery(window).resize(function() {
var maxHeight = -1;
$('.product-item').each(function() {
if ($(this).find('.product-item-brand').height() > maxHeight) {
maxHeight = $(this).find('.product-item-brand').height();
}
});
$('.product-item-brand').height(maxHeight);
var maxHeight1 = -1;
$('.product-item').each(function() {
if ($(this).find('.product-item-link').height() > maxHeight) {
maxHeight = $(this).find('.product-item-link').height();
}
});
$('.product-item-link').height(maxHeight);
});
.product-items {
list-style-type: none;
display: flex;
flex-wrap: wrap;
}
.product-item {
max-width: 200px;
max-height: 262px;
text-align: center;
}
.product-item-name {
border: 1px solid red;
a {
text-decoration: none;
}
}
.product-item-link {
-webkit-box-orient: vertical;
display: -webkit-box;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
.product-item-brand {
line-height: 15px;
border: 1px solid black;
}
.product-price {
margin-top: 20px;
line-height: 19px;
border: 1px solid green;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ol class="products list items product-items">
<li class="product-item">
<div class="product-item-info">
<div class="product details product-item-details">
<div class="product-item-brand">
this one have brand name
</div>
<div class="product name product-item-name">
<a class="product-item-link" href="#">long word goes here will break in 2 rows, qwerty 123456</a>
</div>
<div class="product-price-block">
<div class="product-price">
$15
</div>
</div>
</div>
</div>
</li>
<li class="product-item">
<div class="product-item-info">
<div class="product details product-item-details">
<div class="product-item-brand">
this one also
</div>
<div class="product name product-item-name">
<a class="product-item-link" href="#">long word goes here</a>
</div>
<div class="product-price-block">
<div class="product-price">
$15
</div>
</div>
</div>
</div>
</li>
<li class="product-item">
<div class="product-item-info">
<div class="product details product-item-details">
<div class="product-item-brand">
next doesnt have, need to set empty space
</div>
<div class="product name product-item-name">
<a class="product-item-link" href="#">long word goes here</a>
</div>
<div class="product-price-block">
<div class="product-price">
$15
</div>
</div>
</div>
</div>
</li>
<li class="product-item">
<div class="product-item-info">
<div class="product details product-item-details">
<div class="product-item-brand">
</div>
<div class="product name product-item-name">
<a class="product-item-link" href="#">long word goes here</a>
</div>
<div class="product-price-block">
<div class="product-price">
$15
</div>
</div>
</div>
</div>
</li>
</ol>
I've got a weird rendering issue in IE concerning an inline unordered list. What I'm trying to do is make a visualizer for the lifespan of a project, but whenever I try to add in any text in my <p> object designed to hold a time period, it shifts the whole <li> element down, but only in Internet Explorer.
Please, take a gander at this issue: https://jsfiddle.net/xny1zv3j/
I'm okay with the name and position (ex: 'John' and 'Project Lead' being pulled down - that's not an issue for me. But in IE, and IE only, it seems as if the entire list element is pulled down. When the <p> element is empty, it's simply ignored, and is fine in all browsers, but when it has content, IE freaks out.
You should be able to simply add vertical-align: top to your .li class.
Is this what you are shooting for? https://jsfiddle.net/xny1zv3j/3/
HTML
<div class="container body-content">
<div class="container" id="main-container">
<ul class="timeline">
<li class="li" >
<div class="timestamp">
<div class="author">John</div>
<div class="date">Project Lead</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Created Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jenny</div>
<div class="date">Programmer</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Built Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jeremy</div>
<div class="date">Marketing</div>
</div>
<div class="status">
<div class="time-period">
<p>2 yrs</p>
</div>
<h4>Advertised Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jack</div>
<div class="date">Sales</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Sold Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jebeddiah</div>
<div class="date">IT</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Defended Project</h4>
</div>
</li>
</ul>
</div>
</div>
CSS
.timeline {
text-align: left;
list-style-type: none;
display: inline-block;
margin-bottom:-23px;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 5px;
padding-right: 5px;
}
.li {
width: 150px;
display: inline-block;
}
.timestamp {
margin-bottom: 20px;
padding: 0px;
font-weight: 100;
display: block;
white-space: nowrap;
overflow: hidden;
}
.status {
padding-top: 10px;
position: relative;
transition: all 200ms ease-in;
white-space: normal;
}
.status h4 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
padding-bottom: 3px;
}
.time-period {
display: inline;
text-align: center; }
.time-period p {
/* margin: -30px 0px 20px;*/
}
.time-period p:empty {
display:inline-block;
}
I am trying to make my list items all the same width. I've tried setting the widths in the css and nothing changes. Can anyone figure this out?
Here is an image to show what I am talking about:
HTML:
<body>
<div class="content-wrapper" id="container">
<header>logo
<nav>navigation</nav>
</header>
<div class="clear-fix"></div>
<div id="body">
<section class="main-content">
<section class="leftPane">
<h2>Categories</h2>
</section>
<section class="rightPane">
<div class="checkout">
<h1>Checkout</h1>
<ul class="steps">
<li><a href="http://localhost:59213/Cart">
<div id="step0" class="arrow_box_grey">
Shopping Cart</div>
</a>
</li>
<li><a href="http://localhost:59213/Cart/Student">
<div id="step1" class="arrow_box_grey">
Student</div>
</a>
</li>
<li><a href="http://localhost:59213/Cart/Delivery">
<div id="step2" class="arrow_box_grey">
Delivery</div>
</a>
</li>
<li>
<div id="step3" class="arrow_box_green">Payment</div>
</li>
<li>
<div id="step4" class="arrow_box_blue">Finish</div>
</li>
</ul>
</div>
</section>
<div class="clear-fix"></div>
</section>
</div>
</div>
And here if my fiddle with the code: http://jsfiddle.net/M74Em/
You need to change this style:
.main-content .checkout ul.steps li div {
display: inline;
width: 1000px;
}
You can't set widths for inline elements so try this:
.main-content .checkout ul.steps li div {
display: inline-block;
width: 100px;
}
Example
From twBootstrap, applied to <ul>'s (demo):
.ul-justified {
display: table;
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
.ul-justified > li {
display: table-cell;
float: none;
width: 1%;
}
and slap .ul-justified to any ul-list you want aligned, and you get equal width <li>'s automatically fit parent ul's width.
Wrong:
Correct:
How to achieve that (without spaces between elements) ? They also must be centered.
HTML:
<div class="header container">
<div class="col col-1">
<input type="text" class="text small" name="search" placeholder="Search suppliers">
</div>
<div class="col col-2">
<div class="styled-select">
<select>
<option>asd</option>
</select>
</div>
</div>
<div class="col col-3">
Reset
Search
</div>
</div>
CSS:
.header {
display: table;
width: 100%;
height: 120px;
text-align: center;
}
.header > div {
display: table-cell;
vertical-align:middle;
}
.col {
width:20%;
}
Anyone can help with that ?
Simply set all div.col with inline-block positioning and set 'text-align:center' on your container to center it horizontally.
.container {
text-align:center;
}
.container .col {
display:inline-block;
}
Use display: inline-block.
.header {
width: 100%;
height:120px;
text-align:center;
}
.col {
display: inline-block;
vertical-align:middle;
}
Also, to remove spaces between each .col, make sure that there is no white space between each opening and closing div tag.
<div class="header container">
<div class="col col-1">
<input type="text" class="text small" name="search" placeholder="Search suppliers">
</div><div class="col col-2"> <!-- THIS LINE - no white-space -->
<div class="styled-select">
<select>
<option>asd</option>
</select>
</div>
</div><div class="col col-3"> <!-- THIS LINE - no white-space also -->
Reset
Search
</div>
</div>
</div>
To get exactly what you want, you'll need an extra HTML wrapper.
http://jsfiddle.net/h37J4/
.header {
width: 100%;
height:120px;
}
.header > .row {
max-width: 360px;
margin: 0 auto;
overflow: hidden; /*quick cleafix hack */
}
.col {
float: left;
}
yoou need a wrapper for the content like this:
<div class="header container">
<div class="wrapper">
<div class="col col-1">
<input type="text" class="text small" name="search" placeholder="Search suppliers">
</div>
<div class="col col-2">
<div class="styled-select">
<select>
<option>asd</option>
</select>
</div>
</div>
<div class="col col-3">
Reset
Search
</div>
<div class="wrapper">
</div>
And then style the wrapper with css, something like this:
.header .wrapper {
width: 70%; /* or any in px */
margin: 0 auto; /* for centering */
}
Or you can just replace your ".header" element's 100% width with smaller number!