Solved

Align=right dosent work ?

Posted on 2014-01-07
4
399 Views
Last Modified: 2014-01-08
Hei!

Have this code for a header:

<header>
<table width="100%" align="left" border="1" padding-right="10px" class="headertabell">
<tr class="rapport1_del5">

<td class="rapport1_del5" align="left">
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Printer </a></td>
<td class="rapport1_del5" align="left">
<a href="MPDF/examples/PDF6.php?brukerID=<?php echo $brukerID ?>&kundeid=<?php echo $kundeid ?>" target="_self"><img src="../images/PDF.png" align="left"/> PDF </a></td>
<td class="rapport1_del5" align="right">
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Logg ut </a></td>
</tr>
</table>

</header >

Open in new window


***** CSS ********
.rapport1_del5
{
    background-color: #efefef;
    border: none ! important;
    box-shadow: none ! important;
    padding-left:15px;
      height:30px;
      padding-top:3px;
}


My problem is this code:
<td class="rapport1_del5" align="right">
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button"

It dosent align="right", but it align="left"  WHY ?
0
Comment
Question by:team2005
4 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 39761579
You have three different definitions:

<tr class="rapport1_del5">

<td class="rapport1_del5" align="left">

<td class="rapport1_del5" align="right">

Open in new window


as well as:

***** CSS ********
.rapport1_del5
{
    background-color: #efefef;
    border: none ! important;
    box-shadow: none ! important;
    padding-left:15px;
      height:30px;
      padding-top:3px;
}

Open in new window


I think the padding-left in the css is trumping your left vs right vs your blank align calls..
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 250 total points
ID: 39761584
Use float: right on the elements, you'll have much more controls over what you want
Here's a test link: http://jsfiddle.net/AlexCode/8avHe/

And here's the changed code:
<header>
    <table width="100%" align="left" border="1" padding-right="10px" class="headertabell">
        <tr class="rapport1_del5">
            <td class="rapport1_del5" align="left">
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Printer </a>
            </td>
            <td class="rapport1_del5" align="left">
<a href="MPDF/examples/PDF6.php?brukerID=<?php echo $brukerID ?>&kundeid=<?php echo $kundeid ?>" target="_self"><img src="../images/PDF.png" align="left"/> PDF </a>
            </td>
            <td class="rapport1_del5" align="right">
                <a href="#" onClick="window.print()"> 
                    <span style="float:right">Log out</span>
                    <img src="../images/skriver.png" TYPE="button" style="float:right" />
                </a>
            </td>
        </tr>
    </table>
</header>

Open in new window


Note that I only changed the part you mentioned and put the style inline.
It's better that you rework this layout a bit and move all styles to the css.
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 250 total points
ID: 39761688
Yes, avoid your inline styles  http://jsbin.com/ATUVuKIN/1/edit?html,output
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
  <style>
    table.headertabell{
  float:left;
  width:100%;
  padding-right:10px;
  border-style:solid;
  border-width:1px;
  
  
}
.leftText{text-align:left;}
.rightText{text-align:right;}
  </style>
</head>
<body>
  <header>
<table class="headertabell">
<tr class="rapport1_del5">

<td class="rapport1_del5 leftText">
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Printer </a></td>
<td class="rapport1_del5 leftText">
<a href="MPDF/examples/PDF6.php?brukerID=<?php echo $brukerID ?>&kundeid=<?php echo $kundeid ?>" target="_self"><img src="../images/PDF.png" align="left"/> PDF </a></td>
<td class="rapport1_del5 rightText" >
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Logg ut </a></td>
</tr>
</table>

</header >
</body>
</html>

Open in new window


I would also consider making 3 div's instead of the table. http://jsbin.com/ATUVuKIN/2/edit?html,output
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
  <style>
    header{
      width:100%;
      border-style:solid;
      border-width:1px;
      height:50px;
    }
  .rapport1_del5{
  float:left;
  width:30%;
  margin-right:1%;

}
.leftText{text-align:left;}
.rightText{text-align:right;}
  </style>
</head>
<body>
  <header>

<div class="rapport1_del5 leftText">
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Printer </a></div>
<div class="rapport1_del5 leftText">
<a href="MPDF/examples/PDF6.php?brukerID=<?php echo $brukerID ?>&kundeid=<?php echo $kundeid ?>" target="_self"><img src="../images/PDF.png" align="left"/> PDF </a></div>
<div class="rapport1_del5 rightText" >
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Logg ut </a></div>

</header >
</body>
</html>

Open in new window

0
 
LVL 2

Author Closing Comment

by:team2005
ID: 39764622
Thanks
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question