https://jsfiddle.net/tbnzaga9/
#smenu a {
color: black;
text-decoration: none;
}
.button:hover {
background-color: #A9A9A9;
}
.button {
position: absolute;
border: 1px solid black;
cursor: pointer;
background-color: #d3d3d3;
width: 30%;
left: 1%;
}
.right {
position: absolute;
right: 60%;
}
#smenu table tr td p {
display: inline-block;
float: left;
}
<div id='smenu'>
<table>
<tr>
<th> Title</th>
<th class='right'> Date</th>
</tr>
<tr>
<td class='button'>test</td>
<td class='right'>
<p>4/27</p>
</td>
</tr>
</table>
</div>
I was making a list of separate websites and the dates they were made, but I can't get them to line up! I tried float:left and display: inline-block, but it's just not lining up. Any suggestions?
Also - is there a better way than using a table?
try these change in CSS.
#smenu a {
color: black;
text-decoration: none;
}
.button:hover {
background-color: #A9A9A9;
}
.button {
border: 1px solid black;
cursor: pointer;
background-color: #d3d3d3;
}
td {
text-align: center;
width: 200px;
height:25px;
}
#smenu table tr td p {
//display: inline-block;
//float: left;
}
Try to replace <p></p> by <div></div> or use a css reset sheet to clear the paragraph doing a line break. Also, I think tables are ok to do things like this, but limit you more. If you really wanted to you could mimic a table with some divs where you have your rows and in each one have your columns you could have differents classes by rows and by column in different rows.
I would remove all "position:absolute".
Given that you have tabular data, it makes sense to just use a regular table tag.
I've also added the following styles:
.right {
padding-right: 60%;
}
#smenu table {
width:100%;
}
.right p {
margin:0px;
}
th {
text-align: left;
}
You can see the changes here:
https://jsfiddle.net/tbnzaga9/2/
Related
I need some help in a sizing question. If you view the following code in desktop browsers, everything is sized as it should be. If you try to open it on a mobile phone (I have tested it with several iPhones), the td (white with grey border) is not resized properly. The td element is resized correct, if there is a span element that's causing the overflow.
div.highlighter-rouge {
overflow-x: scroll;
}
div.highlight {
width: 100%;
}
.highlight {
display: inline-block;
}
.highlight {
background-color: #eeeeee;
}
pre.highlight {
margin-top: 0;
margin-bottom: 0;
}
pre code {
white-space: pre;
}
table {
margin: 15px 0;
padding: 0;
}
table {
word-wrap: anywhere;
}
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0;
}
table tr td {
border: 1px solid #cccccc;
text-align: left;
margin: 0;
padding: 6px 13px;
}
table tr th :last-child,
table tr td :last-child {
margin-bottom: 0;
}
table tr th :first-child,
table tr td :first-child {
margin-top: 0;
}
td.rouge-code>pre>span {
display: inline-block;
}
.highlight .nt {
color: #000080;
}
.highlight .s1 {
color: #d01040;
}
html {
-webkit-text-size-adjust: 100%;
}
<div class="language-bash highlighter-rouge">
<div class="highlight">
<pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2</pre>
</td>
<td class="rouge-code">
<pre>ausearch <span class="nt">-c</span> <span class="s1">'ajp-bio-0:0:0:0'</span> <span class="nt">--raw</span> | audit2allow <span class="nt">-M</span> my-ajpbio0000
semodule <span class="nt">-i</span> my-ajpbio0000.pp</pre>
</td>
</tr>
</tbody>
</table</code>
</pre>
</div>
</div>
I've tried many things now, but my level of knowledge about this, just leads to trial and error. If you don't really like the solution with tables, I can also create a version with the exact same behaviour without them.
https://codepen.io/ribbonCaptain/pen/GRrqgpE
.rouge-table td {
vertical-align: top;
}
.rouge-table td pre {
white-space: pre-wrap;
}
...will do it. See it here.
There's not much to explain.
I have text and image in the td tag. The text is stay still but trying to text-align: right; an image. So I used span class on the image. But image doesn't listen to command still next to the text, not going right corner.
<td>マンションを購入しようとした時に何から始めたら良いでしょうか
<span class="open-button-big">
<img src="img/open-button-big.png" class="open-button-big-class">
</span>
</td>
it's looking like :
and this is the CSS
table {
margin-top: 20px;
display: none;
}
table {
border-top: solid 1px blue;
}
tr {
border-top: solid 1px blue;
}
th {
text-align: center;
padding: 10px 10px 10px 10px;
}
td {
font-size: 14px;
}
.Question {
width: 40px;
}
span {
text-align: right !important;
}
.open-button-big-class {
width: 70px;
height: auto;
}
Since span is an inline elements and it wraps the image you should set it's display to block or use a div instead. To align the whole span to the right, use float: right
table {
margin-top: 20px;
width: 100%;
}
table {
border-top: solid 1px blue;
}
tr {
border-top: solid 1px blue;
}
td {
font-size: 14px;
}
span {
float: right !important;
display: block;
}
.open-button-big-class {
width: 70px;
height: auto;
}
<table>
<tr>
<td>マンションを購入しようとした時に何から始めたら良いでしょうか
<span class="open-button-big">
<img src="https://www.reduceimages.com/img/share-icon.png" class="open-button-big-class">
</span>
</td>
</tr>
</table>
You can use this:
span {
float: right !important;
}
But I strongly recommand using this kind of css selector:
table td span {
float: right !important;
}
Because if you select just span, all of spans will get this style, using specific selection in better for controlling over other spans
I am a newbie to css.
I have two td in a row of which first has overflow visible. The contents in the first div are overlapping with the second td as in the example below. I wish to make the div css properties like cursor: pointer over the second td. Thus, the div css properties should be on top of the second td.
Please help me with this.
https://jsfiddle.net/jt00uk3e/
Thanks.
table {
width: 0px;
table-layout: fixed;
}
td {
width:50px;
height:50px;
overflow: visible;
}
#td1 {
background-color: red;
}
#td2 {
background-color: green;
}
#div2 {
width: 200px;
height: 20px;
background-color: blue;
cursor: pointer;
}
<table>
<tr>
<td id="td2"><div id="div2"></div></td>
<td id="td1"></td>
</tr>
</table>
Add z-index to div
#div2 {
width: 200px;
height: 20px;
background-color: blue !important;
cursor: pointer;
position:relative;
z-index:
https://jsfiddle.net/jt00uk3e/6/
try this:
table {
width: 0px;
table-layout: fixed;
}
td {
width:50px;
height:50px;
overflow: visible;
}
#td1 {
background-color: red;
}
#td2 {
background-color: green;
}
#div2 {
position:relative;
z-index:1;
width: 200px;
height: 20px;
background-color: blue;
cursor: pointer;
}
<table>
<tr>
<td id="td2"><div id="div2"></div></td>
<td id="td1"></td>
</tr>
</table>
I have the following DOM structure:
JSFiddle demo
<table class="tbl">
<tr>
<th>
<td>
<div>
<span>
A lot of text in hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
</span>
</div>
</td>
<td>
<div>
<span>
A lot of text in hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
</span>
</div>
</td>
</th>
</tr>
</table>
table.tbl{
background-color: #FFF;
border: 1px solid #000;
border-collapse: separate;
border-radius: 5px;
float: left;
margin: 10px 0;
width: 100%;
}
table.tbl tr {
font-weight: 400;
text-align: left;
}
table.tbl th {
color: #FFF;
font-weight: 400;
padding: 6px;
text-align: left;
}
table.tbl td {
padding: 10px 8px;
}
table.tbl div {
max-width: 100%;
display: inline-flex;
}
table.tbl span {
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
This table is located on the right hand side of my page, but if there is a large amount of text in one or both of the span tags, the table extends extends off my page.
I have to keep the table at width: 100% as it needs to fill all available space on the right hand side of my page.
Can I add a CSS ellipsis to the span tag but keep the overall width of the table at width: 100%?
It doesn't seem to be working for me at the moment, any suggestions or advice would be greatly appreciated.
you can try his one:
table.tbl{
background-color: #FFF;
border: 1px solid #000;
border-collapse: separate;
border-radius: 5px;
float: left;
margin: 10px 0;
width: 100%;
table-layout: fixed;
}
table.tbl tr {
font-weight: 400;
text-align: left;
}
table.tbl th {
color: #FFF;
font-weight: 400;
padding: 6px;
text-align: left;
}
table.tbl td {
padding: 10px 8px;
}
table.tbl div {
max-width: 100%;
display: inline-flex;
}
table.tbl span {
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
DEMO HERE
I'm using tables for semantic markup but styling them to resemble lists of multiple lines with icons to the left: http://jsfiddle.net/qs1zsL2s/
However, the inline-styled cells are shown one pixel down from the icons. How do I prevent this, so they begin at the same y-position?
HTML:
<table>
<tbody>
<tr><td><img src="http://www.w3.org/html/logo/downloads/HTML5_Logo_256.png" alt="HTML5 logo"></td><td>First cell</td><td>Second cell</td><td>Third cell</td></tr>
<tr><td><img src="http://www.w3.org/html/logo/downloads/HTML5_Logo_256.png" alt="HTML5 logo"></td><td>First cell</td><td>Second cell</td><td>Third cell</td></tr>
</tbody>
</table>
CSS:
td {
display: inline;
background-color: red;
}
td:first-child {
display: block;
float: left;
}
td:last-child {
display: block;
}
img {
height: 48px;
}
Just updated your fiddle: Fiddle
Just add vertical-align: top to your td
td {
display: inline;
background-color: red;
vertical-align:top;
}
For reference: https://developer.mozilla.org/en/docs/Web/CSS/vertical-align
You can simply add in the CSS properties position:relative and top:1px:
td:first-child {
display: block;
float: left;
position: relative;
top: 1px;
}
fiddle