Page 1 of 1
how do i align these links to the right?
Posted: Mon Feb 07, 2011 4:49 pm
by peachiness
Code: Select all
<?php
if(@$_SESSION['log']){
echo "<a href=\"?page=upload\">Upload</a> ";
echo " | <a href=\"?page=logout\">Log out</a>";
}
else
echo "<a href=\"?page=login\">Log in</a> ";
echo " | <a href=\"?page=home\">Help</a> ";
?>
Re: how do i align these links to the right?
Posted: Mon Feb 07, 2011 10:58 pm
by Starkid225
Its not really a text align but you could try to float the links
Replace:
Code: Select all
<?php
if(@$_SESSION['log']){
echo "<a href=\"?page=upload\">Upload</a> ";
echo " | <a href=\"?page=logout\">Log out</a>";
}
else
echo "<a href=\"?page=login\">Log in</a> ";
echo " | <a href=\"?page=home\">Help</a> ";
?>
With:
Code: Select all
<?php
if(@$_SESSION['log']){
echo "<a style='float: right' href=\"?page=upload\">Upload</a> ";
echo " | <a style='float: right' href=\"?page=logout\">Log out</a>";
}
else
echo "<a style='float: right' href=\"?page=login\">Log in</a> ";
echo " | <a style='float: right' href=\"?page=home\">Help</a> ";
?>
Re: how do i align these links to the right?
Posted: Tue Feb 08, 2011 12:19 am
by social_experiment
@peachiness : What does your css look like?
Re: how do i align these links to the right?
Posted: Wed Feb 09, 2011 10:27 am
by peachiness
Starkid225 : It moved the link to the right of the other link...but they stayed on the left side of the page ><
social_experiment: here is the css
Code: Select all
@charset "utf-8";
td
{
background-color: white;
border-top: solid 1px black;
border-bottom: solid 1px black;
}
tr
{
background-color: white;
}
.missInformation
{background-color: white;
margin-left: 80%;
}
a
{
text-decoration: none;
}
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}
.twoColLiqLtHdr #container {
width: 80%; /* this will create a container 80% of the browser width */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
color: #000;
}
.twoColLiqLtHdr #header {
background: #DDDDDD;
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
}
.twoColLiqLtHdr #header h1 {
margin: 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
padding-top: 20px;
padding-right: 0;
padding-bottom: 20px;
padding-left: 20px;
}
/* Tips for sidebar1:
1. since we are working in percentages, it's best not to use padding on the sidebar. It will be added to the width for standards compliant browsers creating an unknown actual width.
2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".twoColLiqLtHdr #sidebar1 p" rule.
3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns.
*/
.twoColLiqLtHdr #sidebar1 {
float: left;
width: 24%; /* since this element is floated, a width must be given */
background: #DDDDDD; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 15px 0; /* top and bottom padding create visual space within this div */
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.twoColLiqLtHdr #sidebar1 a{
text-decoration: underline;
}
.twoColLiqLtHdr #sidebar1 h3, .twoColLiqLtHdr #sidebar1 p {
margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 10px;
font-weight: bold;
}
/* Tips for mainContent:
1. the space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 430px or smaller (this includes images).
3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs.
*/
.twoColLiqLtHdr #mainContent {
width: 66%;
margin: 0 20px 0 26%; /* the right margin can be given in percentages or pixels. It creates the space down the right side of the page. */
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.twoColLiqLtHdr #footer {
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
background:#DDDDDD;
margin: 0 10px 0 10%;
width: 78.6%;
}
.twoColLiqLtHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
}
/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
tab
{
text-indext:40px;
}
text1 {
margin:15px;
font-size:12px;
font-style:bold;
color:#00F;
indent-text:50px;
}
text2{
font-style:normal;
color:#000;
margin:15px;
font-size:10px;
}
Re: how do i align these links to the right?
Posted: Wed Feb 09, 2011 10:48 am
by pickle
Moving to UI design forum.
Re: how do i align these links to the right?
Posted: Thu Feb 10, 2011 12:17 am
by social_experiment
You can add another div around the links
Code: Select all
<div class="navigation">
<?php
if(@$_SESSION['log']){
echo "<a href=\"?page=upload\">Upload</a> ";
echo " | <a href=\"?page=logout\">Log out</a>";
}
else
echo "<a href=\"?page=login\">Log in</a> ";
echo " | <a href=\"?page=home\">Help</a> ";
?>
</div>
Then in your css place the following
Code: Select all
div.navigation {
text-align: right;
}
Hth
Re: how do i align these links to the right?
Posted: Fri Feb 11, 2011 11:31 am
by peachiness
I appreciate your advice so much. I tried that but the links are so stubborn and did not budge one bit. =_=
social_experiment wrote:You can add another div around the links
Code: Select all
<div class="navigation">
<?php
if(@$_SESSION['log']){
echo "<a href=\"?page=upload\">Upload</a> ";
echo " | <a href=\"?page=logout\">Log out</a>";
}
else
echo "<a href=\"?page=login\">Log in</a> ";
echo " | <a href=\"?page=home\">Help</a> ";
?>
</div>
Then in your css place the following
Code: Select all
div.navigation {
text-align: right;
}
Hth
Re: how do i align these links to the right?
Posted: Fri Feb 11, 2011 4:18 pm
by social_experiment
Which browser/s are you testing with and what does the complete code on that page look like? It's possible that somewhere the links are inhereting a value that stops them aligning right.
Re: how do i align these links to the right?
Posted: Mon Feb 14, 2011 10:34 am
by peachiness
social_experiment wrote:Which browser/s are you testing with and what does the complete code on that page look like? It's possible that somewhere the links are inhereting a value that stops them aligning right.
I am testing it on firefox and the following is the complete code:
Code: Select all
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Publications and Presentations</title>
<link href="twoColLiqLtHdr.css" rel="stylesheet" type="text/css" /><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColLiqLtHdr #sidebar1 { padding-top: 30px; height: 900px; }
.twoColLiqLtHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<h1></h1>
<style type="text/css">
.twoColLiqLtHdr #container #header h1 {
color: #0033cc;
}
.twoColLiqLtHdr #container #mainContent h2 strong {
color: #0033cc;
}
.twoColLiqLtHdr #container #mainContent h2 {
color: #0033cc;
font-size:20px;
}
p
{
font:"Times New Roman", Times, serif;
font-size:12px;
}
p.sideheading
{
color:#0033cc;
font-weight:bold;
}
ul
{
list-style-image:url("images/blueSqu.jpg");
list-style-type:square;
font:"Times New Roman", Times, serif;
font-size:12px;
}
a:link {color:#0033cc;} /* unvisited link */
a:visited {color:#333399;} /* visited link */
a:hover {color:#ff6600;} /* mouse over link */
a:active {color:#003366;} /* selected link */
#header a
{
text-decoration: none
}
</style>
</head>
<body class="twoColLiqLtHdr">
<div id="container">
<div id="header">
<h1><img src="images/tamuLogoA.jpg" width="311" height="74" alt="TAMU Logo" />
<a href="" >Water and Energy Economics</a></h1>
<!-- end #header --></div>
<!-- <hr size="4" color="#0033cc" >
<hr size="4" color="#f4af00" >
-->
<img src="images/bars2.jpg" width=100% alt="2 horizontal bars" />
<br>
<div id="sidebar1">
<h3><img src="images/AgriLifeLogo.jpg" alt="AgriLife Research Logo" align="center" width=100% height=15% " /></h3>
<hr color="#dddddd"/>
<hr color="#0033cc"/>
<hr color="#dddddd"/>
<!-- end #sidebar1 --></div>
<div id="mainContent">
<?php
$indexCheck = "yes";
require('config.php');
session_start();
if(@$_POST['validate'] == "true")
{
if($_POST['username'] == $username1)
{
if($_POST['password'] == $password1)
{
$_SESSION['log'] = true;
}
}
}
if(@$_SESSION['log'])
$userCheck = "admin";
?>
<div style="display: table;">
<div style="display: table-cell;" id="cell1">
<?php
if(@$_SESSION['log']){
echo "<a href=\"?page=upload\">Upload</a> ";
echo " | <a href=\"?page=logout\">Log out</a>";
}
else
echo "<a href=\"?page=login\">Log in</a> ";
echo " | <a href=\"?page=home\">Help</a> ";
?>
</div>
</div>
<br />
<div style="display: table-cell;" id="cell2">
<?php
//Pages
$page = @$_GET['page'];
if(($page == null) || ($page == "view"))
{
require('view.php');
}
else if($page == "upload")
{
require('upload.php');
}
else if($page == "home")
{
require('home.php');
}
else if($page == "edit")
{
require('edit.php');
}
else if($page == "login")
{
require('login.php');
}
else if($page == "logout")
{
require('logout.php');
}
else
{
require('error.php');
error('404');
}
?>
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<div id="footer">
<p><a href="http://h20mc2economics.tamu.edu/index.html">Return to Home Page</a></p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>
Re: how do i align these links to the right?
Posted: Tue Feb 15, 2011 7:20 pm
by Starkid225
First of all I don't see anything that would even make the links go the right. I don't know if you took it out because it wasn't working or not but your <div> that the links are placed in is using an id of "cell1". Even looking in your CSS i couldn't find that declared. If you add this to your CSS it might work:
Remember if you are not using a CSS file for your CSS code you will need to place it in between these style tags:
Re: how do i align these links to the right?
Posted: Wed Feb 16, 2011 12:43 am
by social_experiment
There isn't a 'table' value for the display property. The options are the following : block, list-item, inline and none. Remove this and value the advice given by Starkid225 and add that rule to your stylesheet.
You shouldn't use the style option as you did in the example. If you validated your page you would probably find it doesn't validate. It's best to seperate the presentation layer (CSS) from the other and keep all your styling in a seperate file. In the long run you save tons of time by editing only 1 file instead of a many.
Re: how do i align these links to the right?
Posted: Wed Feb 16, 2011 2:12 pm
by peachiness
Yes, I took the tags out because they did not work. I've tried everything..from putting those links in divs and aligning div to the right, floating the links, using Starkid's suggestion to align cell1 to the right..
None of these methods work..I don't really know what to do
