how to format text to align in two columns - css

First off the title may not be clear but i dont know to come up with a better one.
i have text that I put in a td cell in a velocity template, something like below
* My name
is what?
what i want is something that more formatted like below.
* My name
is what?
"My name is what?" is variable i print and all i do is concatinate * to it and put in the cell for display
what can be done to make it happen. i am not sure of the best way to start off with. I use IE8

Here is one possible solution that may work for you:
Demo Fiddle
Instead of separating content into different elements and positioning them (or nesting them). I thought a simple before class could work well in this situation.
HTML:
<div class="copy-block">
My name is what?
</div>
CSS:
.copy-block {
width: 60px;
position: relative;
}
.copy-block:before {
content: "*";
position: absolute;
left: -15px;
top: 3px;
}

The name is variable. The output on two lines can be solved with adding a break in the table cell.
table {
border: 1px solid gray;
font: 12px arial;
border-collapse: collapse;
}
td {
border: 1px solid gray;
}
.asterix-name {
position: relative;
padding: 5px 5px 5px 15px;
}
.asterix-name:before {
content:'* ';
position: absolute;
left: 5px;
top: 0.5em;
}
<table>
<tr>
<td>
<div class="asterix-name">My name<br> is what?</div>
</td>
</tr>
</table>
http://jsfiddle.net/Fb7jT/49/

Related

How do i add rounded borders to my b-table using only CSS

I want to have my b-table have rounded borders
I've tried multiple different solutions I found online but it still hasn't worked out for me
For reference, this is what I want my table to look like in terms of borders:-
And this is my current table:-
for my CSS I've used the following:-
.content-table {
border-collapse: separate;
margin: 25px 0;
font-size: 0.9em;
min-width: 400px;
overflow: hidden;
border: 2px solid #5B5B5B;
border-radius: 15px;
background-color: #5B5B5B;
border-spacing: 0;
}
However, as my current table image show, this means my rows do not have their top or bottom headers
I have also tried using border-collapse: collapsed without the border-spacing 0 but then I will get a result like this:-
However, this is also an issue whereby the border is extending over in all the corners
Any assistance would be greatly appreciated!
Adding rounded border to a table is little bit tricky,
table { position:relative;max-width:600px }
table::after {
content: " ";
inset: 0;
border: solid #000 1px;
position: absolute;
border-radius: 20px;
}
DEMO

Can't use classes or id's in CSS

I'm trying to use classes and/or id's to style paragraphs and other elements. I've used them successfully before, but on this page the only id that works is for styling an image. However, if I use the tag for a paragraph then the styling works in CSS. I would like the id "#1p" in the CSS to allow me to style the corresponding paragraph. Right now this id acts as if it is not there. Below is my code:
table {
position: absolute;top: 50px;
left: 225px;
width: 650px;
border: 10px solid black;
border-collapse: collapse;
padding: 5px;
}
th {
font-family: sans-serif;
font-size: 24px;
text-align: left;
color: #f2f2f2;
background-color: black;
}
.positionImage {
position: absolute;
top: 50px;
left: 140px;
border: 10px solid black;
}
h2 {
text-align: center;
position: absolute;
top: 160px;
left: 300px;
}
#1p {
position: absolute;
top: 200px;
left: 175px;
font-size: 18px;
}
<img src="Pen_MLA.jpg" class="positionImage">
<table>
<th colspan="2">The Writing Center at Bristol Community College</th>
<tr>
<td><b>Building B - Room 117</b></td>
<td><b><i>E-mail: writing.center#bristolcc.edu</i></b></td>
</tr>
<tr>
<td><b>508-678- 2811 X2544<b></td>
<td><b><i>Website: www.bristolcc.edu/writingcenter</i></b></td>
</tr>
</table>
<h2>Quoting and Citing Poetry (MLA)</h2>
<p id="1p">(Material is drawn from the <u>MLA Handbook for Writers of
Research Papers</u>, 6th Edition.)</p>
A CSS ID selector consists of:
a "number sign" (U+0023, #) immediately followed by the ID value, which must be an CSS identifiers.
An identifier:
cannot start with a digit
If you want to represent an ID starting with a digit then you must either:
use an escape sequence: #\31p {}
use an attribute selector (warning: this changes the specificity): [id="1p"]
change the HTML ID
HTML IDs cannot start with numbers. You site is styled fine if you use p1 rather than 1p.
You can read more about this, and a possible workaround (you can use [id='1p'] if you really need to) here.

I can't find an error, text-align in th tag

I can't find error, trying this for the last 1h.
Here is page http://kushke.5gbfree.com/SecondPage.html
I want to center "To do list" header
table {
border: 3px solid orange;
background-color: yellow;
width: 100%;
text-align: center;
}
td, th {
color: black;
border: 2px dashed black;
}
#th1 {
padding-right: 160px;
text-align: center;
}
<table>
<tr>
<th id="th1" nowrap><h3>To do list</h3></th>
<th><h3>Done</h3></th>
<th><h3> Hard</font></h3></th>
</tr>
</table>
The problem appears to be
#th1 {
padding-right:160px;
}
If you need padding, add it to both sides of the th:
#th1 {
padding-left: 20px;
padding-right: 20px;
}
You shouldn't use the padding property to maintain a certain width for the column of your table. By adding a padding property, you lose the center alignment.
So, remove
#th1 {
padding-right: 160px;
align: center;
}
and replace it with the code below:
#th1 {
width: 180px;
padding: auto;
}
Of course, you can set your custom width by modifying the value at the code snippet above.
Try to add this to th element: To do list
Because of your help, I have solved this.
No further comments needed, but if you want upvotes, write anything,
I will respond.
Best regards!

css - Table immune to browser zoom

Ok, i have a wordpress site, i added a table and use the
white-space: no-wrap;
Since i want the table headers to stay on a single line, the table have too many headers and need to make to stay outside of the content "boundary" (that is fine with me).
The problem is that when i zoom in and out with the browser, the table change position (moves a lil bit left or right and dosnt stay centered) i center it manualy with the "margin".
Im very new to css, hope i describe the issue enough.
.dataTables_wrapper .tablepress {
white-space: nowrap;
clear: both;
margin-left: -50px;
}
.entry table {
border: 1px solid #DFDFDF;
background-color: #F9F9F9;
width: 100%;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
font-family: Arial,"Bitstream Vera Sans",Helvetica,Verdana,sans-serif;
color: #333;
border-collapse: separate;
border-spacing: 0;
}
.tablepress {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
margin-bottom: 1em;
border: 0;
}
Does setting a width not work?
<table>
<tr>
<td>stuff</td>
<td>stuff</td>
</tr>
</table>
table{border:1px solid #000;width:100%}
link to fiddle
It might also help if you provided a little more information, like where abouts on your page you want to put this table

I don't understand why an ID is not more specific than a class

I've got:
<div class="cardDisplay">
<img class="cardImg" id="cardImg4" alt="Card" src="picture.jpg" width="148" height="236.8" title="">
</div>
Here's my CSS.
.cardDisplay
{
width: 1020px;
background-color: #040D14;
margin: auto;
position: relative;
}
.cardImg
{
padding:0px;
padding-left: 40px;
padding-right: 0px;
/* background-color: black; */
}
#cardImg4
{
border: 20px solid white;
padding-right: 30px:
}
The problem is I cannot get the, I thought, more specific ID to override the class. I've tried doing it a number of different ways with no luck. I'm using Chrome if that matters. Thanks.
You have a colon : instead of a semi-colon ; in your padding-right style for #cardImg4. The rule probably isn't being applied at all.
You should be aware that you have a : not ; after the #cardimg4 padding-right. This might affect it.

Resources