I'm floating two divs side by side. I can't set the properties for the left div as they seem to be inherited from the right div. I'm guessing I"m just overlooking something here, but what do I need to do so I they aren't inherited?
div.main - content {
width: 1500 px;
}
div.left {
float: left;
width: 300 px;
overflow: hidden;
background - color: #ffffff;
}
table.;
left {
border - collapse: collapse;
width: 300 px;
}
table.left, td {
border: 1 px hidden black;
padding: 5 px;
background - color: #ffffff;
color: #000000;
}
div.right {
float:right;
width:1200px;
overflow:hidden;
}
table.right {
border-collapse:collapse;
width:765px;
}
table.right, th {
border: 1px solid black;
padding:5px;
background-color:# df1e37;
color: #ffffff;
}
table.right, td {
border: 1 px dotted# cccccc;
padding: 5 px;
background - color: #ffffff;
color: #000000;
}
<div class="main-content">
<div class="left">
<table class="left">
<tr>
<td>Left content here</td>
</tr>
</table>
</div>
<div class="right">
<table class=right>
<tr>
<td>Right content here</td>
</tr>
</table>
</div>
</div>
table.;left should be table.left, for starters. Also, as #3rror404 points out, the comma in your selectors may not mean what you think:
table.left, td
means "a table element with class left, and also td elements", whereas
table.left td
means "a table element's children tds".
After the semicolon change, though, things look OK for me. A possible change you may consider is not putting classes on the tables:
<div class="left">
<table>
<tr><td>Left content here</td></tr>
</table>
</div>
and accessing them this way:
div.left table { ... }
or
div.left > table { ... }
...which IMO would eliminate a possible source of future confusion.
There were a few typo in your code
table.;left => .left table
and a few more similar to that... here is the new snippet
div.main-content {
width:1500px;
}
.left {
float:left;
width:500px;
overflow:hidden;
background-color:rgba(123,123,123,0.1);
}
.left table {
background-color: #feade2;
border-collapse:collapse;
width:300px;
}
.left table td {
color:#000000;
}
.right {
float:right;
width:1000px;
overflow:hidden;
background-color:rgba(200,200,200,0.3);
}
.right table {
border-collapse:collapse;
width:765px;
}
.right table th {
border: 1px solid black;
padding:5px;
color:#ffffff;
}
.right table td {
background-color:blue;
color:red;
}
<div class="main-content">
<div class="left">
<table>
<tr><td>Left content here</td></tr>
</table>
</div>
<div class="right">
<table>
<tr><td>Right content here</td></tr>
</table>
</div>
</div>
I added some colors to differentiate various boundaries... you can change the css the way you want it.
you also dont need div.left or div.right . Just use .left or .right and just specify the class on the div...the table will inherit the classes of the div. Hope this helps
Related
I am trying to work with CSS and containers without success, I would like if someone helps:
I am trying to do as the specified with the following code, the table is okay is fulfilled the 100% of the 40% of body Container1 DIV, the problem is with the rows and the columns, they don't follow the specification.
<div id="CamadaSuperior" >
<table id="tabela">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
<div id="CamadaDoMeio" >
CamadaDoMeio
</div>
<div id="CamadaInferior" >
<table class="TabelaDaCamadaInferior" border="1">
<tr><td>Esquerda</td><td>Meio</td><td> Direita</td></tr>
</table>
</div>
<div id="CamadaRodape" >
</div>
</body>
My CSS is this:
html, body{
height: 100%;
margin:0;
padding:0;
}
div{
border:1px solid black;
padding:0;
}
#CamadaSuperior
{
height: 40%;
}
#CamadaDoMeio
{
height: 10%;
}
#CamadaInferior
{
height: 40%;
padding:0;
}
#CamadaRodape
{
height: 10%;
padding:0;
}
#tabela{
height:100%;
table-layout: fixed;
border-width:1px;
}
#tabela tr{
width:50%;
height:100%;
border-width:1px;
}
#tabela tr td{
width:100%;
height:16.7%;
}
.TabelaDaCamadaInferior
{
height: 100%;
width: 100%
}
.TabelaDaCamadaInferior tr td
{
width:33%;
}
But this is what is happening with table row:
TD tag does not work as well:
Well the short answer is to make use of a CSS framework like bootstrap, it can be used in an eclipse environment and just attach the classes you need in order to get it to position correctly. Check the link here https://www.texniq.de/en/web-engineering-i/create-first-bootstrap-project
The long answer is that you need to style each td & tr with a class that has the width and height that you want. You'll also need to adjust the font-size accordingly so that the text in each cell will fit properly. Right now the table has some css applied but the tags within it are using their default values.
I'm creating a website for a school project using HTML and CSS. In the header there is a table and I need a text (which is inside a cell) to be aligned on the vertical center and on the horizontal right.
This is the HTML code
<table id="intestazione">
........
<tr>
<td class="centerV"><h1>Text</h1></td>
<td><img src="Logo.jpg"></td>
</tr>
</table>
and this is the CSS code
h1
{
font-family:Arial;
font-size:50px;
color:#009ED9;
text-align:right;
}
.centerV
{
display:table-cell;
vertical-align:middle;
}
but it doesn't work as I want, so I changed the CSS code into
h1
{
font-family:Arial;
font-size:50px;
color:#009ED9;
display:table-cell;
vertical-align:middle;
text-align:right;
}
and the text is vertically centered, but not on the right (it is on the left). I've read that I can use line-height or a padding on the top, but in my opinion it is more clean and elegant to use vertical-align (tell me if I am wrong).
I tried also other code from suggestions on the web but I don't write it otherwise the question will be too long.
you can use :
position : relative;
right : value%;
(or left:value%)
as you like ..
check this
<table id="intestazione" border="1">
<tr>
<td class="centerV"><h1>Text</h1></td>
<td><img src="http://www.sec4ever.com/home/images/misc/noavatar.gif"></td>
</tr>
h1{
font-family:Arial;
font-size:50px;
color:#009ED9;
display:table-cell;
padding:100px;
vertical-align:middle;
position:relative;
right:30%; }
Take out display:table-cell from your h1 headings and simply apply a text-align:right to your td elements.
h1 {
font-family: Arial;
font-size: 50px;
color: #009ED9;
text-align: right;
}
.centerV {
vertical-align: middle;
}
tr {
border: solid red;
}
td {
border: solid green;
width: 100%;
}
h1 {
font-family: Arial;
font-size: 50px;
color: #009ED9;
vertical-align: middle;
text-align: right;
}
h1 {
border: solid red;
}
table {
text-align: right;
}
<table id="intestazione">
........
<tr>
<td class="centerV">
<h1>Text</h1>
</td>
<td><img src="Logo.jpg"></td>
</tr>
</table>
You can use align="right" in td by default content is vertically aligned in td.
<table id="intestazione" width="100%" bgcolor="green">
<tr>
<td align="right" valign="middle" ><h1>Text</h1></td>
<td><img src="Logo.jpg"></td>
</tr>
</table>
try this
h1 {
font-family:Arial;
font-size:50px;
color:#085ED9;
display:table-cell;
vertical-align:middle;
float: right;
}
I read this article: How to make a vertical line in HTML
but the height style didn't work for <th> tags
My CSS is like this:
.verticalLine
{
width: 1px;
background-color: Black;
height: 10px;
}
My HTML is this:
<th class="verticalLine"></th>
Unfortunately, the vertical line spans the whole border. I have tried percentages instead of pixels, to no avail.
Edited
.navCenter
{
text-align:center;
display:table-cell;
}
<nav style="margin-left:auto; margin-right:auto; width: 70%; height:55px;">
<table>
<tr class="navCenter">
<th><h2><img src="Pictures/BartleHallToppers.jpg" height="42px" width="100px"/></h2></th>
<th class="verticalLine"></th>
<th><h2>Events</h2></th>
<th><h2>Restaurants</h2></th>
<th><h2>Hotels</h2></th>
<th><h2>Points of Interest</h2></th>
<th><h2>Public Works</h2></th>
<th><h2>Road Construction</h2></th>
<th><h2>Contact Us</h2></th>
</tr>
</table>
</nav>
using tables is not a good practice for creating a navigation
you can ul li and for border pseudo
JS Fiddle
li:not(:last-child):after {
content:"|";
position:absolute;
right:0;
top:0;
}
or
li:not(:last-child):after {
content:" ";
width:1px;
position:absolute;
border-right:1px solid;
right:0;
top:0;
bottom:0;
}
Using tables for creating nav menu is not a best practic, but your code must works, if you put th into table:
.verticalLine
{
width: 1px;
background-color: Black;
height: 10px;
}
<table>
<th class="verticalLine"></th>
</table>
`
I'm having some trouble with the positioning of tooltips on a column of data within a table, which itself is inside a vertical scrolling div. A little background for you...
Due to legacy issues which are beyond my control, the page I am developing has to be displayed through an iframe of fixed width and height. The data I need to display has about 12 columns, all of which are required to be displayed. One column will contain serial numbers, which sometimes end up overflowing the bounds of the cell. I've set the overflow of this column to show an ellipsis, and have added tooltips as described in the accepted answer to this question.
When the tooltips are added, it appears to take the distance from the top of the table to the hovered cell, and draw the tooltip that distance from the top of the parent div. This means that, when you scroll down through the div, the tooltips end up being drawn down below the bottom of the div.
I've created a jsFiddle which demonstrates this: http://jsfiddle.net/kuzxLwxe/4/
Here's my css:
.ResultsWrapper {
width:150px;
height:314px;
text-align:center;
overflow-x:hidden;
overflow-y:scroll;
border:1px solid black;
}
.ResultsTable {
width:86px;
border-collapse:collapse;
table-layout:fixed;
}
.ResultsTable th, .ResultsTable td {
border:1px solid black;
overflow:hidden;
text-overflow:ellipsis;
}
.ColumnSerialNo {
width:81px;
}
.hasTooltip span {
display: none;
color: #000;
text-decoration: none;
padding: 3px;
}
.hasTooltip:hover span {
display: block;
position: absolute;
background-color: #FFF;
border: 1px solid #CCC;
margin: 2px 10px;
}
And my html:
<div class="ResultsWrapper">
<table class="ResultsTable">
<thead>
<tr>
<th class="ColumnSerialNo">Serial Number</th>
</tr>
</thead>
<tbody>
<tr>
<td class="hasTooltip">3119985815206<span>3119985815206</span></td>
</tr>
<tr>
<td class="hasTooltip">5665811486586<span>5665811486586</span></td>
</tr>
...
</tbody>
</table>
</div>
I'm using jQuery for other things within the same page, but so far haven't been able to come up with a solution with it. If you think the best way to fix this is by using JS or jQuery I'd love to see the result!
Thanks in advance
Change your HTML markup to take more control on overflow:
<tr>
<td class="hasTooltip">
<div class="SerialNumberContainer">
<div class="SerialNumber">3119985815206</div>
<div class="SerialNumberTooltip">3119985815206</div>
</div>
</td>
</tr>
And in your CSS, remove overflow from td:
.ResultsTable th, .ResultsTable td {
border:1px solid black;
/* overflow: hidden; this line should delete */
text-overflow:ellipsis;
}
And new CSS:
.SerialNumberContainer {
position: relative;
z-index: 10;
}
.SerialNumber {
width: 80px;
overflow: hidden;
}
.SerialNumberTooltip {
position: absolute;
top: 10px;
left: 2px;
background-color: #FFF;
border: 1px solid #CCC;
display: none;
}
.SerialNumberContainer:hover {
z-index: 20;
}
.SerialNumberContainer:hover .SerialNumberTooltip {
display: block;
}
JSFiddle Demo.
I've been recently working on a simple web page. I would like to place almost all style info in the CSS file. The main layout of the page is a table. I looks like this:
<body>
<table class="glowna">
<tr>
<td colspan="2">...</td>
</tr>
<tr>
<td id="glowna_top" colspan="2">
<ul class="menu_gorne">
<li>..</li>
</ul>
</td>
</tr>
<tr>
<td id="glowna_menu_lewe">
<ul class="menu_lewe">
<li>...</li>
</ul>
</td>
<td id="glowna_main">
...
</td>
</tr>
</table>
</body>
and the CSS is like:
ul.menu_lewe, ul.menu_gorne {
display:block; list-style:none;margin:0;}
ul.menu_lewe {
width:200px; padding:2px 20px 2px 2px;
background-color:#9ce;border:none; vertical-align:top;}
ul.menu_lewe li {
border-bottom:1px solid #9ce; }
ul.menu_lewe a:link, ul a:visited {
display:block;width:176px;text-decoration:none;padding:7px;font- weight:bold;background-color:#27c;color:#def;border-right:10px solid #25b;border-left:5px solid #25b; }
ul.menu_lewe a:hover {
width:176px;background-color:#28e;color:#fff;border-right:20px solid #26d; }
ul.menu_gorne {
position:absolute; }
ul.menu_gorne li {
float:left;padding:2px 2px 2px 2px;background-color:#9ce;border:none; }
ul.menu_gorne a:link, ul a:visited {
text-decoration:none;display:block;width:200px;text-align:center;padding:5px 0;font-weight:bold;background-color:#27c;color:#def;border-top:10px solid #25b; }
ul.menu_gorne a:hover {
background-color:#28e;color:#fff;border-top:20px solid #26d; }
ul.lista_dostawcow {
width:800px;}
table.glowna {
background-color:#9ce;table-layout:fixed;width:1024px;margin-left:auto;margin-right:auto; }
td#glowna_top {
height:55px; vertical-align:top;}
td#glowna_main {
width:824px; text-align:left;}
td#glowna_menu_lewe {
width:200px;}
The problem is:
1. that even I set all the widths I still get table cells: "glowna_menu_lewe" and "glowna_main" divided 50%:50%. I want cell "glowna_menu_lewe" to be only 200px or sth near and the other one may fill the rest of space.
2. I would like to place list "menu_lewe" on top of its cell. Now it is vertically centered even that I set the verical-align attribute to top.
Sorry for posting so much code but I didn't know what may be causing the problem.
1 - Change that :
table.glowna {
background-color:#9ce;
table-layout:fixed;
width:1024px;
margin-left:auto;
margin-right:auto;
}
td#glowna_main {
width:824px;
text-align:left;
}
to this :
table.glowna {
background-color:#9ce;
width:1024px;
margin-left:auto;
margin-right:auto;
}
td#glowna_main {
text-align:left;
}
2- use valign="top" attribute to td tag instead of vertical-align:top;