I have a table and what I want is to not make the space between the content as big. This is what the page looks like right now:
So this is some of the code for the table (I'm not posting it all because it's repetitive, all the tags are closed at the end too).
I have tried changing the padding and margin and it doesn't work. This is the CSS:
/*styling the table for the add ons*/
table,
tr,
td,
input {
margin: 30px;
padding: 10px;
margin-right: 20px;
margin-left: 45px;
line-height: 1.4em;
font-size: 17px;
}
.pushRight {
position: relative;
left: 10px;
bottom: 75px;
}
<table style="width:100%">
<tr>
<td><label><input type="checkbox" name="example" value="Value"><span><b>Voice over artist</b> €475</span>
<table>
<tr>
<td class="pushRight">If you require a voice artist for your video project<br>please select this option.</td>
</tr>
</table>
</td>
<td><label><input type="checkbox" name="example" value="Text"><span><b>Creative Concept</b> €1200</span>
<table>
<tr>
<td class="pushRight">We are bursting with ideas, so if you don't have one of<br>your own please select this option.</td>
</tr>
</table>
</td>
</div></tr>
<tr><div class="secondRow">
<td><label><input type="checkbox" name="example" value="Value"><span><b>Script</b> €850</span></label>
<table>
<tr>
<td class="pushRight">If you would like us to allocate our scriptwriter to your project<br>please select this option.</td>
</tr>
</table>
</td>
<td><label><input type="checkbox" name="example" value="Text"><span><b>Storyboarding</b> €875</span>
<table>
<tr>
<td class="pushRight">It is not essential to storyboard every video project, <br>however if you would like to include this process,<br>please select this option.</td>
</tr>
</table>
</td>
</div></tr>
First of all, you have some divs that don't do much in your html(div with class second row), when you use tables, the tr tags define the rows automatically, so you don't have to put a div to say that's my first row etc...
Using a lot of margin, and padding everywhere will make your table look ugly depending on which browser you're using, i tried to reorganize your code and just added this in your css :
td{
padding : 20px
}
table{
margin: 0 auto;
}
All you have to do now is to play with the padding to change the space as you want. you can also change the width of the table if you want a bigger table.
Here's a jsfiddle :
https://jsfiddle.net/rfroq680/2/
I had this recently, you need to use border-spacing in css.
Try this:
table{
border-collapse:separate;
border-spacing:0 6px;
}
You'll get 6px between rows with the above code.
This should help too: https://www.w3schools.com/cssref/pr_border-spacing.asp
Related
I have an HTML table, with three columns.In the second column, I added a simple style as shown below.
table {
border: 1px solid black;
}
.requiredBar {
background-color: #c00;
}
.requiredCol {
width: 1px;
max-width: 1px;
}
<table>
<tr>
<td>Name</td>
<td class="requiredCol requiredBar"> </td>
<td><input type="text" /></td>
</tr>
<tr>
<td>Password</td>
<td class="requiredCol requiredBar"> </td>
<td><input type="text" /></td>
</tr>
</table>
The output that I am getting is like this. The red bar shown is actually a column. I am trying to reduce its height without changing the height of other cells in the same row.
Is it possible to change the height of some cell (red bar in this case) in an html table of the same row?
You can add a div inside your requiredCol and set its height
table {
border: 1px solid black;
}
.requiredBar {
background-color: #c00;
height: 10px;
width: 2px;
display: block;
}
.requiredCol {
width: 2px;
}
<table>
<tr>
<td>Name</td>
<td class="requiredCol">
<div class="requiredBar"></div>
</td>
<td><input type="text" /></td>
</tr>
<tr>
<td>Password</td>
<td class="requiredCol">
<div class="requiredBar"></div>
</td>
<td><input type="text" /></td>
</tr>
</table>
You can't change one cell height without changing row height in a table(actually that's a standard) and that leads table to change some other cells in table.
If you want to ordering some tags (like input and label in this case) its better to use CSS Grid Layout instead of table.
If you insist on using table,you can set the position of item ,which stay in cell with flexbox instead of changing exact cell.
The main idea behind the flex layout is to give the container the ability to alter its items' width/height (and order) to best fill the available space.
I'm developing a website for a company right now. I've done a table and now they say that the td must be also a link. The problem is that one td has three lines and the three lines must be the same link tag. I used a paragraph tag inside the link to change the line height, because they want the three lines with less line space, but it leaves a top space that must be removed. I've tried changing the margin-top, padding-top, td height... Nothing seems to work. If someone can help me I'll appreciate it.
Thank you.
Here's my code:
<table>
<tr>
<th>COMUNITAT</th>
<td>Bé comú</td>
<td>Glocalitat</td>
<td>Cercle</td>
<td>Lideratge</td>
<td>Comunicació</td>
<td>Famílies</td>
</tr>
<tr>
<th>EDUACIÓ</th>
<td>Aprenentatge</td>
<td>Qualitat</td>
<td>Idiomes</td>
<td>Personalització</td>
<td>Llenguatges</td>
<td>Creativitat</td>
</tr>
<tr>
<th>CARÀCTER</th>
<td>Identitat</td>
<td>Espiritualitat</td>
<td>Fet religiós</td>
<td>Equitat</td>
<td>Passió</td>
<td>Rol educador</td>
</tr>
<tr style='border:none !important; vertical-align: top;'>
<th>ENTORN</th>
<td>
<a href="#">
<p>Escola<br/>Universitat<br/>Empresa</p>
</a>
</td>
<td>Oberts</td>
<td>Tecnologia</td>
<td>Arquitectura</td>
<td>Oferta</td>
<td>Transformadors</td>
</tr>
</table>
And here's my actual CSS:
table a p {
font-size: 100%;
text-align: left;
line-height: 1;
}
Edit: This is how it looks currently.
I'm trying to show movie info for a website, but I'm having issues with the CSS and HTML. I want the title (Director:, Cast:, etc) to be in line with the first item in the list, and then have all others follow below. I tried a definition list, but couldn't figure out the css to make it responsive. Now I have a table, but I'm starting to suspect a regular list might be better.
Here is my fiddle which looks how I want it to when the window is wide enough, but gets ruined when shrunk down to mobile (which is when I want the Cast: columns to become one column)
Any help would be super appreciated, I've been playing with this for months.
Here's my html:
<div class="movieinfo">
<table>
<tr class="spaceUnder">
<td class="workheader">Director:</td>
<td>John Carney</td>
</tr>
<tr class="spaceUnder">
<td class="workheader">Writer:</td>
<td>John Carney</td>
</tr>
<tr>
<td class="workheader">Cast:</td>
<td>Keira Knightly</td>
<td class="spacedRight">James Corden</td>
</tr>
<tr>
<td></td>
<td>Mark Ruffalo</td>
<td class="spacedRight">CeeLo Green</td>
</tr>
<tr>
<td></td>
<td>Hailee Steinfeld</td>
<td class="spacedRight">Catherine Keener</td>
</tr>
<td></td>
<td>Adam Levine</td>
</table>
</div>
and my CSS:
.movieinfo {
color: #333333;
font-size: 24px;
line-height: 1.1;
font-weight: 300;
padding: 20px;
background-color: rgba(255,255,255,.7);
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
margin-bottom: 20px;
}
You are partially misusing the table for layout here by putting the cast names in separate cells. Don't let your design requirements influence your decision on how to markup the data. This includes using appropriate HTML elements such as <th> for header cells:
<div class="movieinfo">
<table>
<tr class="spaceUnder">
<th>Director:</th>
<td>John Carney</td>
</tr>
<tr class="spaceUnder">
<th>Writer:</th>
<td>John Carney</td>
</tr>
<tr>
<th>Cast:</th>
<td>
<ul>
<li>Keira Knightly</li>
<li>James Corden</li>
<li>Mark Ruffalo</li>
<li>CeeLo Green</li>
<li>Hailee Steinfeld</li>
<li>Catherine Keener</li>
<li>Adam Levine</li>
</ul>
</td>
</tr>
</table>
</div>
To format the cast in columns there are two options depending on if you want to order the items primely vertically or horizontally. For vertical ordering use columns:
.movieinfo ul {
-webkit-columns: 3 10em;
-moz-columns: 3 10em;
columns: 3 10em;
}
EDIT: When using both a width and a number form columns, then the number is the maxmium number of columns displayed. The gap between the columns can be set with column-gap.
More complete example: http://jsfiddle.net/owdz2m0m/
Or for horizontal use floats:
.movieinfo ul > li {
float: left;
width: 10em;
}
EDIT: Limiting the number of columns with floats is a bit trickier. You'll need to set the max-width of the surrounding element (in this case the ul) to the "column width * maximum Number of columns". So to limit the columns to 2 set .movieinfo ul { max-width: 20em; }
More complete example: http://jsfiddle.net/tr9e8bmv/
In either case you can use media queries at adjust the widths depending on screen size.
I think, You need #media queries. Something like this:
#media only screen and (max-width: 640px){ your style }
And You can build your HTML width <dl> and <ul>
DEMO
If You change window size on demo, You can see how 2 columns become 1 column. Screen 1, Screen 2
Is it possible to place a character on a border line displayed in a table?
I am trying to discover a way to re-create musical staff notation for webpages using html rather than inserting images.
I have actually got the staff itself to render fine, 5 horizontal lines divided by vertical bars using this in my css header:
table.musStaff{border-collapse:collapse;}
.trms{border-bottom:2px solid black;}
.tdms{border-left:2px solid black;}
and this where I need to render a musical staff:
<table class="musStaff">
<tr><td> <td> <td> </td></tr>
<tr class="trms"><td> <td> <td> </td></tr>
<tr class="trms"><td> <td class="tdms"> <td class="tdms"> </td></tr>
<tr class="trms"><td> <td class="tdms"> <td class="tdms"> </td></tr>
<tr class="trms"><td> <td class="tdms"> <td class="tdms"> </td></tr>
<tr class="trms"><td> <td class="tdms"> <td class="tdms"> </td></tr>
<tr><td> <td> <td> </td></tr>
</table>
All the are merely included as temporary place holders.
So my problem is I need to be able to place ● chars representing notes on the lines as well as between the lines, rendered by the <tr class="trms"> (border-bottom:2px solid black).
Other than that I think I would be good to go.
Is this what you are trying to achieve?
HTML
<div><span>o</span></div>
CSS
div {
border-right: 1px solid black;
display: inline-block;
font-size: 20px;
line-height: 20px;
height: 1em;
position: relative;
width: 1em;
}
span {
position: absolute;
right: -5px;
}
jsfiddle
You can position anything anywhere you like if you are willing to get into the details and cross-browser issues of css positioning.
For example:
<td style="position:relative; top:-12px">●</td>
http://jsfiddle.net/markm/2ft3ojbn/
If I were working on this, however, I would seriously look at using svg or the canvas instead of html and css — this is the kind of task these tools are made for. In the end it will be much more maintainable and readable. It will also be easier to program. In fact there are some libraries out there already to help — for example:
http://www.vexflow.com
I have an div container where an image is displayed, above that image I would like to show an table. So, my problem is that the table isn't displayed over the image. Instead it is shown after the image? Can somebody tell me how I can align the table above the image?
<div id="foto2">
<img src="foto2.jpg" class="bg"> <span class="oben">
<table>
<tr>
<td onclick="playAudio('test.mp3')">Hamdullah</td>
<td onclick="playAudio('test2.mp3')">Was?</td>
</tr>
<tr>
<td onclick="playAudio('test.mp3')">Penner</td>
<td onclick="playAudio('test2.mp3')">Heidefick</td>
</tr>
</table>
</span>
</div>
And my css:
html, body {
margin: 0;
width: 100%;
height: 100%;
background-color:#00061c;
}
img.bg {
width: 100%;
}
.oben {
left: 0;
width: 100%;
}
#font-face {
font-family: "Hallo";
src: url(hallo.ttf);
}
table {
width:100%;
color:#FFF;
}
tr {
text-align:center;
}
td {
font-family: Hallo;
font-size: xx-large;
}
In order to see your table "above" ( I suppose you mean in the z axis.) so the image is displayed as a background of the table you can use 2 alternatives solutions
1) a background for your foto2 div.
2) an absolute positioned table
Alternative 1 : Background for your foto2 div.
I dont think you need that oben rule with a left property for a not positioned element (which actually wont work either). The span tag as well I will keep it out of the game unless you have a very particular reason for it...mmmm
This is the fiddle
This is the css for foto2 div. You may adjust the repeat and other properties at your will
#foto2 {
background:url( your image url here );
}
this is the html
<div id="foto2">
<table>
<tr>
<td onclick="playAudio('test.mp3')">Hamdullah</td>
<td onclick="playAudio('test2.mp3')">Was?</td>
</tr>
<tr>
<td onclick="playAudio('test.mp3')">Penner</td>
<td onclick="playAudio('test2.mp3')">Heidefick</td>
</tr>
</table>
</div>
Alternative 2: Absolute positioned table
With this alternative you may use a full width image and not to be constrained by the table size. its your call which alternative to use
Your foto2 div should be relative positioned.Then....
table {
position:absolute;
top:0px;
width:100%;
color:#FFF;
}
And here the fiddle for the absolute table
Have you tried putting the image after the table, like?
</table>
<img src="foto2.jpg" class="bg" />
Or put it in the lowest row of the table like:
<tr>
<td onclick="playAudio('test.mp3')">Penner</td>
<td onclick="playAudio('test2.mp3')">Heidefick</td>
</tr>
<tr>
<td><img src="foto2.jpg" class="bg"></td>
</tr>
</table>
By the way why are you using <span> and put the <table> inside it?
Try inserting it after the closing span tag
<div id="foto2">
<span class="oben">
<table>
<tr>
<td onclick="playAudio('test.mp3')">Hamdullah</td>
<td onclick="playAudio('test2.mp3')">Was?</td>
</tr>
<tr>
<td onclick="playAudio('test.mp3')">Penner</td>
<td onclick="playAudio('test2.mp3')">Heidefick</td>
</tr>
</table>
</span>
<img src="foto2.jpg" class="bg" />
</div>