Solved

Align=right dosent work ?

Posted on 2014-01-07
4
385 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now