473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Alignment problems

Hi

I'm strugleing with laying out a page masthead with an image to the
left and right and some text in the middle and all inline with each
other. Here's my html and css so far:

<style type="text/css">
div#header {
margin: 0 auto;
padding: 0;
width: 100%;
color: #fff;
background: #5A5D5A;
border-bottom: 2px solid #fff;
}

div#header h1 {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
width: 33%;
}

div#header a#left-link {
margin: 0;
padding: 0;
float: left;
width: 33%;
}

div#header a#right-link {
margin: 0;
padding: 0;
float: right;
width: 33%;
}
</style>

....html...

<div id="header">
<a href="#" id="left-link">
<img src="/admin/images/empetus-logo.gif" width="182" height="34"
alt="Empetus website" />
</a>

<h1>Admin Area</h1>

<a href="#" id="right-link">
<img src="/admin/images/wrench.gif" width="30" height="30"
alt="Request support" />
</a>
</div>

I've tried a number of methods including float: left and float: right
on the links but I never seem to be able to get the line up I need. Do
I need to wrap each element i.e. the [a href] in divs of their own and
if so what should the css look like?

Many thanks
Andrew
Jul 20 '05 #1
4 1864
In article <a8**************************@posting.google.com >,
Andrew Jocelyn <an************@empetus.co.uk> wrote:
Hi

I'm strugleing with laying out a page masthead with an image to the
left and right and some text in the middle and all inline with each
other. Here's my html and css so far:

<style type="text/css"> [snip]div#header h1 {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
width: 33%;
}
The first thing people here will tell you is to define your font-size
in em of %, not px or pt. This allows people using IE to
automagically resize the text as they need directly from their tool
bar.

[snip]
I've tried a number of methods including float: left and float: right
on the links but I never seem to be able to get the line up I need. Do
I need to wrap each element i.e. the [a href] in divs of their own and
if so what should the css look like?
No. All you need to do is move the right link above the h1 like this:
<div id="header">
<a href="#" id="left-link">
<img src="/admin/images/empetus-logo.gif" width="182" height="34"
alt="Empetus website" />
</a>

<a href="#" id="right-link">
<img src="/admin/images/wrench.gif" width="30" height="30"
alt="Request support" />
</a>
</div>

<h1>Admin Area</h1>


Although the elements are floating left or right, that only sets their
horizontal position. Their vertical position is dependent on their
natural flow in the document. A header (like h1) implies a line
break, so the img after it is moved down some.

I'm still somewhat new at this, so I attempted defining all the
elements as inline to see if that would work, but it didn't in IE6
(Windows).

Oh, and one other thing. You've got to watch your spacing when
putting images in anchors (<a>). When you have newlines between the
anchor begin and end elements and the image, you sometimes get
unwanted space around the image.

--
lkseitz (Lee K. Seitz) .at. hiwaay @dot@ net
".zihW zeehC stae nataS"
-- "Weird Al" Yankovic, "Nature Trail to Hell"
Jul 20 '05 #2
In article <10*************@corp.supernews.com>, Lee K. Seitz <lkseitz> wrote:
The first thing people here will tell you is to define your font-size
in em of %, not px or pt.


Oops. Make that "em *or* %." Amazing the difference one mistyped
letter makes. 8)

--
lkseitz (Lee K. Seitz) .at. hiwaay @dot@ net
'90s flashback: I've fallen, and I can't get up!
Jul 20 '05 #3
On Thu, 12 Feb 2004 20:50:10 -0000, lkseitz (Lee K. Seitz) .at. hiwaay
@dot@ net wrote:
In article <a8**************************@posting.google.com >,
Andrew Jocelyn <an************@empetus.co.uk> wrote:

I'm strugleing with laying out a page masthead with an image to the
left and right and some text in the middle and all inline with each
other. Here's my html and css so far:

<style type="text/css">

[snip]
div#header h1 {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
width: 33%;
}


The first thing people here will tell you is to define your font-size
in em of %, not px or pt. This allows people using IE to
automagically resize the text as they need directly from their tool
bar.

Quibble: this actually helps users of most (all?) graphical browsers,
not just IE, as they don't have to readjust their zoom for every site
they come across. But it's more important for IE users than others.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #4
Stephen Poley <sb******************@xs4all.nl> wrote in
news:h8********************************@4ax.com:
On Thu, 12 Feb 2004 20:50:10 -0000, lkseitz (Lee K. Seitz) .at. hiwaay
@dot@ net wrote:

The first thing people here will tell you is to define your font-size
in em of %, not px or pt. This allows people using IE to
automagically resize the text as they need directly from their tool
bar.


Quibble: this actually helps users of most (all?) graphical browsers,
not just IE, as they don't have to readjust their zoom for every site
they come across. But it's more important for IE users than others.


That's a little misleading, since users will still have to readjust their
zoom for sites where the author sets their text to a percentage or em value
that's too small. It's specifically an IE bug that makes such adjustment
difficult with pixel-sized text. I just don't want authors to get the
impression that using ems or percents is a license to request microfonts.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: J. Campbell | last post by:
I posted a question some time back about accessing a char array as an array of words. In order not to overrun the char array, I padded it with enough 0x00 bytes to ensure that when accessed as...
23
by: Ken Turkowski | last post by:
The construct (void*)(((long)ptr + 3) & ~3) worked well until now to enforce alignment of the pointer to long boundaries. However, now VC++ warns about it, undoubtedly to help things work on 64...
67
by: S.Tobias | last post by:
I would like to check if I understand the following excerpt correctly: 6.2.5#26 (Types): All pointers to structure types shall have the same representation and alignment requirements as each...
13
by: sachin_mzn | last post by:
Hi, What is the concept of memory alignment? Is memory alignment differs, If a data type is local to a function or if it is a member of structure or union? How 32 to 64 bit processor afftects the...
5
by: Hendrik Schober | last post by:
Hi, we just run into the problem, that "default" alignment in the project properies dialog seem to be different. We have a project that's a DLL, which is linked with a couple of LIBs. All are...
10
by: haomiao | last post by:
I want to implement a common list that can cantain any type of data, so I declare the list as (briefly) --------------------------------------- struct list { int data_size; int node_num;...
4
by: myfavdepo | last post by:
Hi friends, i am having some trouble in my prog. with struct member alignment. I have two different static libraries that i use, each with "struct member alignment" set to 8 bytes. In my...
10
by: Lionel B | last post by:
Greetings, I have some code that is to read unformatted data from disc and interpret it as blocks of unsigned integers. In an attempt to achieve efficiency (it is pretty essential for my...
33
by: silpau | last post by:
struct a { int b; char a; int c; } On i386 the sizeof this structure would be 12 bytes,as 3 bytes are padded after a so that c is aligned on 4byte boundary.
8
by: Stephen Horne | last post by:
I understand that the next C++ standard will have features to handle the alignment of data types. This is good, but a bit late for me! I've been using some template trickery to handle alignment...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.