Jump to content
  • 0

Выравнивание в столбце


Тёмик
 Share

Question

Доброго времени суток!

Хочу во втором столбце сделать выравнивание текста по правой стороне. Вроде должно быть так, но работать не хочет. Укажите на ошибку.

<style type="text/css">
.pricelist {
border-collapse: collapse;
}

.pricelist TD, .pricelist TH {
padding: 3px;
border: 1px solid #228B22;
}

.pricelist TD {
background: #F0FFFF;
}

.pricelist .category {
background: #008000;
color: white;
font-weight: bold;
text-align: center;
}
</style>

<table width="600px" cellpadding="0" cellspacing="0" class="pricelist">
<col width="500px" align="left">
<col width="100px" align="right">

<tr>
<td colspan="2" class="category">Заголовок</td>
</tr>
<tr>
<td>4234</td>
<td>аваи</td>
</tr>
<tr>
<td>ааывп</td>
<td>343455</td>
</tr>

<tr>
<td colspan="2" class="category">Заголовок 2</td>
</tr>
<tr>
<td>4234</td>
<td>аваи</td>
</tr>
<tr>
<td>ааывп</td>
<td>343455</td>
</tr>

</table>

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Доброго времени суток!

Хочу во втором столбце сделать выравнивание текста по правой стороне. Вроде должно быть так, но работать не хочет. Укажите на ошибку.

<style type="text/css">
.pricelist {
border-collapse: collapse;
}

.pricelist TD, .pricelist TH {
padding: 3px;
border: 1px solid #228B22;
}

.pricelist TD {
background: #F0FFFF;
}

.pricelist .category {
background: #008000;
color: white;
font-weight: bold;
text-align: center;
}
</style>

<table width="600px" cellpadding="0" cellspacing="0" class="pricelist">
<col width="500px" align="left">
<col width="100px" align="right">

<tr>
<td colspan="2" class="category">Заголовок</td>
</tr>
<tr>
<td>4234</td>
<td>аваи</td>
</tr>
<tr>
<td>ааывп</td>
<td>343455</td>
</tr>

<tr>
<td colspan="2" class="category">Заголовок 2</td>
</tr>
<tr>
<td>4234</td>
<td>аваи</td>
</tr>
<tr>
<td>ааывп</td>
<td>343455</td>
</tr>

</table>

Присвойте класс для td второго столбца(например second) и для него пропишите

text-align: right;


<table width="600px" cellpadding="0" cellspacing="0" class="pricelist">
<col width="500px" align="left">
<col width="100px" align="right">

<tr>
<td colspan="2" class="category">Заголовок</td>
</tr>
<tr>
<td>4234</td>
<td class="second">аваи</td>
</tr>
<tr>
<td>ааывп</td>
<td class="second">343455</td>
</tr>

<tr>
<td colspan="2" class="category">Заголовок 2</td>
</tr>
<tr>
<td>4234</td>
<td class="second">аваи</td>
</tr>
<tr>
<td>ааывп</td>
<td class="second">343455</td>
</tr>
</table>

<style type="text/css">
td.second{
text-align:right;
}
</style>

Edited by flintovich
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy