I am trying to center a table in markdown so i was thinking of putting it inside a div and then text-align the content to center.
<div class="myWrapper" markdown="1">
| Col1 | Col2 | Col3 |
| ------ | ------ | ------ |
| r0 | r0 | r0 |
| r1 | r1 | r1 |
| r2 | r2 | r2 |
| r3 | r3 | r3 |
| r4 | r4 | r4 |
</div>
But doing this will transform it into pure HTML
My question is: How can i use that markdown table inside a div ? And get properly rendered
This answer is aside of the question. I was solving the problem of defining different table styles inside one Markdown document. I'm using Python-Markdown.
The default table stile:
Item No | Name | Description | Price
--------|------|-------------|------
1 | Chair | Kitchen chair | 101.50
2 | Table | Kitchen table | 450.00
The "plated" table style:
<div class="tablePlated"></div>
|Item No | Name | Description | Price|
|--------|------|-------------|------|
|1 | Chair | Kitchen chair | 101.50|
|2 | Table | Kitchen table | 450.00|
And the "gridded" table style:
<div class="tableGridded"></div>
Item No | Name | Description | Price
--------|------|-------------|------
1 | Chair | Kitchen chair | 101.50
2 | Table | Kitchen table | 450.00
Here are the CSS rules:
table {
font-size: 16px;
}
td, th {
padding: 7px 14px;
}
div.tablePlated+table {
border-spacing: 1px;
border-collapse: separate;
}
div.tablePlated+table td, div.tablePlated+table th {
background-color: lightblue;
}
div.tableGridded+table {
border-spacing: 0;
border-collapse: collapse;
}
div.tableGridded+table td, div.tableGridded+table th {
border: solid 1px dodgerblue;
}
And here is the result:
Look at this
Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style emphasis inside an HTML block.
but
Unlike block-level HTML tags, Markdown syntax is processed within span-level tags.
Related
I am trying to make a table with rows that take up only the space they need vertically. Is there any way to do this with CSS without setting the last cell to a height of 100%?
This question is pretty similar to this question only in the other direction.
Currently looks like this:
---------------------------------
| |
|thing 1 |
| |
---------------------------------
| |
|thing 2 |
| |
---------------------------------
| |
|thing 3 |
| |
--------bottom of table----------
how do I get it to look like
---------------------------------
|thing 1 |
---------------------------------
|thing 2 |
---------------------------------
|thing 3 |
| |
| |
| |
| |
| |
| |
--------bottom of table----------
or, alternatively like:
---------------------------------
|thing 1 |
---------------------------------
|thing 2 |
---------------------------------
|thing 3 |
--------bottom of table----------
-----bottom of containing div------
You could set the height of the tr to 1px for all rows but the last.
html, body{width:100%;height:100%;margin:0;}
table{
table-layout:fixed;
height:100%;
}
table tr{height:1px;}
table tr:last-child{height:auto;}
table td{vertical-align:top;border:1px solid #ccc;}
<table>
<tr><td>line 1</td></tr>
<tr><td>line 2</td></tr>
<tr><td>line 3</td></tr>
<tr><td>line 4</td></tr>
<tr><td>line 5</td></tr>
<tr><td>last line</td></tr>
</table>
use this line of CSS selector :
tr:last-child { height:300px; }
You can use css :last-child like:
tr:last-child
I need to display div's equal in height and width with AngularsJS that needs to make a 7x5 square:
----------------------
| | | | | | | |
----------------------
| | | | | | | |
----------------------
| | | | | | | |
----------------------
| | | | | | | |
----------------------
| | | | | | | |
----------------------
I could easily use flex and md-wrap to have this automatically breakline, but it's not possible with 7 div's in a row. Because:
container = 100%
container/7 = 14.28
but values can only be 10 or 15!
I need to use Angular, so I need this structure:
<div ng-repeat="item in Ctrl.items">
{{item}}
</div>
You can use the CSS:
div:nth-of-type(8n) {
...
}
to give every 8th div a specific display behaviour
(eg. using either clear or flex).
Example:
div {
float: left;
}
div:nth-of-type(8n)::before {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: left;
}
You can use the nth-child and after pseudo selcetors, as demonstrated in this jsfiddle:
div {
display:inline;
}
div:nth-child(7n) {
color:red
}
div:nth-child(7n):after {
content:' ';
display:block;
}
I have a question - trying to find a solution here, but that what I see is not as my situation. So:
In TABLE1 we have some article descriptions
ID | Name
1 | Doors
2 | Chairs
In TABLE2 we have a article properties
ID |ID_article | Descr
1 |1 | Type
2 |1 | Material
3 |2 | Height
4 |2 | Width
5 |2 | Toll
In TABLE3 we have a article list with properties values like
Article | ID_art_descr | ID_art_prop | Value
Model1 | 1 | 1 | Solid
Model1 | 1 | 2 | Wood
Model2 | 1 | 1 | Solid
Model2 | 1 | 2 | Steel
The goal is to build a table, which list article from given group with properties for that group. for example, for doors, the table must have columns:
Article | Type | Material
Model1 | Solid | Wood
Model2 | Solid | Steel
For Chairs, the table must have other columns:
Article | Height | Width | Toll
........
So for every article group, the columns count and lables will be different. I was write script on aspx and php which do this, but that method have difficults with sorting or filtering the result table (in some case, we have more than 10k ot rows). So I wonder is there a way to generate a result table on MySQL?
And here is the sqlfiddle description for Table1, Table2 and Table3:
http://sqlfiddle.com/#!2/53e32/1
Thank you strawberry
I have a page in which I have a structure of divs in an inline block. Now each of the block divs have a minimum size and when the window size reduces to a size smaller than the sum of all the inner divs minimum width, I move some of the elements to the next line. I would now like a padding to be added to the div which moves to the next line alone and I am not looking to use js to achieve this. How can I do this in just CSS?
<div width="100%">
<div style="display:inline-block; width=33%; max-width=300px; min-width=135px">
<div style="display:inline-block; width=33%; max-width=300px; min-width=135px">
<div style="display:inline-block; width=33%; max-width=300px; min-width=135px">
</div>
Rendering
------------------- ------------------- -------------------
| | | || |
| | | || |
| div1 | | div 2 || div 3 |
| | | || |
------------------- ------------------- -------------------
constrained space
------------------- -------------------
| | | |
| | | |
| div1 | | div 2 |
| | | |
------------------- -------------------
<^margin 5px inserted^>
-------------------
| |
| |
| div 3 |
| |
-------------------
You can use media queries to apply CSS rules based on the width of the viewport.
#media all and (max-width: _width_value_) {
/* When the screen size is less than or equal to _width_value_ the css rules here will apply */
}
Here's a jsfiddle offering a solution to your original question.
margin-bottom will do the trick, however, it'll be there even when all of the divs are on one line. There's no other way without the JavaScript imho:
.innderDiv {
display:inline-block;
width: 33%;
max-width: 300px;
min-width: 135px;
border: 1px dashed;
margin-bottom: 5px;
}
http://jsfiddle.net/ruslans/KNDFE/
Unfortunately I have to support IE7 (and preferably IE6)
In IE8, Safari, Firefox, Chrome, I get a perfectly good layout ujsing an outer div to enlose two boxes.
------------------------------------
| |
| -------------- ----------- |
| | | | | |
| | A | | B | |
| | | | | |
| -------------- ----------- |
| |
------------------------------------
I'm using inline-block to style A and B. A is floated left, B right. Both boxes have internal divs and other elements.
However, when I use IE6 and IE7 I get this monstrosity.
------------------------------------
| |
| -------------- |
| | | |
| | A | |
| | | |
| -------------- |
| ----------- |
| | | |
| | B | |
| | | |
| ----------- |
| |
------------------------------------
Any definitive answers to what is going on and how to solve it?
Firstly, put a DOCTYPE at the top of your document. This forces IE into standards compliant rather than quirks mode (both euphemisms). For example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Secondly, if you want IE6 compatibility use floats (Andrew is quite correct in stating that display: inline-block only works in IE7 on elements with natural display: inline and <div> has natural display: block). This should work:
<div id="outer">
<div id="left"></div>
<div id="right"><>/div>
</div>
with:
#outer { overflow: hidden; }
#left { float: left; }
#right { float: right; }
as long as the widths of left and right are less than the width of outer including padding, borders and margins. If not, right will drop down to the next line.
In IE 6 and 7 inline-block works only on elements that have a natural display: inline. Are your boxes <div>s? If yes, it should work.. Do you have a test case? (See quirksmode.org for more info!)
IE block level element inline-block hack: this may be useful for you