473,396 Members | 1,789 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,396 software developers and data experts.

How to center some text nicely between two floats

Hi,

There is a little problem with the header on the page I recently
converted from frames to proper HTML+CSS. The top part with the
navigation used to be the top frame but is now included via SSI. On a
broad screen, it looks good, but if you make the viewport small, the
slogan text in the middle overlaps with the navigation buttons.

http://www.weltladen-tuebingen.de/

I experimented with the following:
- put the slogan line between the floats. This results in the right
float being pushed down
- instead of position:relative and top:1em (they belong together,
obviously, the one does nothing without the other), tried margin-top: 1
em, but that shifts the floats down as well.

So what I want is that the slogan is nicely centered between the floats,
both vertically and horizontally, but that it doesn’t overlap with the
line below if the viewport gets small. I do not really understand why
clear:both on the line doesn’t work as expected. float: center; would
be the solution, but this doesn’t exist.

Any hints most welcome.

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Oct 10 '08 #1
6 2729
In article <gc**********@newsserv.zdv.uni-tuebingen.de>,
Hendrik Maryns <gt*******@sneakemail.comwrote:
Hi,

There is a little problem with the header on the page I recently
converted from frames to proper HTML+CSS. The top part with the
navigation used to be the top frame but is now included via SSI. On a
broad screen, it looks good, but if you make the viewport small, the
slogan text in the middle overlaps with the navigation buttons.

http://www.weltladen-tuebingen.de/

I experimented with the following:
- put the slogan line between the floats. This results in the right
float being pushed down
- instead of position:relative and top:1em (they belong together,
obviously, the one does nothing without the other), tried margin-top: 1
em, but that shifts the floats down as well.

So what I want is that the slogan is nicely centered between the floats,
both vertically and horizontally, but that it doesn’t overlap with the
line below if the viewport gets small. I do not really understand why
clear:both on the line doesn’t work as expected. float: center; would
be the solution, but this doesn’t exist.
You could set a min-width so that, if the viewport is shrunk, you
don't observe the behaviour (the user gets a horizontal scroll-bar
instead)

As far as three things on the same line, you can have two left floats
(#logo, #slogan) and leave the right content in the main flow. Or, do
what you're currently doing but with the min-width to prevent collapse
I'm sure there will be plenty of other (better) suggestions...
Oct 10 '08 #2
David Stone schreef:
In article <gc**********@newsserv.zdv.uni-tuebingen.de>,
Hendrik Maryns <gt*******@sneakemail.comwrote:
>Hi,

There is a little problem with the header on the page I recently
converted from frames to proper HTML+CSS. The top part with the
navigation used to be the top frame but is now included via SSI. On a
broad screen, it looks good, but if you make the viewport small, the
slogan text in the middle overlaps with the navigation buttons.

http://www.weltladen-tuebingen.de/

I experimented with the following:
- put the slogan line between the floats. This results in the right
float being pushed down
- instead of position:relative and top:1em (they belong together,
obviously, the one does nothing without the other), tried margin-top: 1
em, but that shifts the floats down as well.

So what I want is that the slogan is nicely centered between the floats,
both vertically and horizontally, but that it doesn’t overlap with the
line below if the viewport gets small. I do not really understand why
clear:both on the line doesn’t work as expected. float: center; would
be the solution, but this doesn’t exist.

You could set a min-width so that, if the viewport is shrunk, you
don't observe the behaviour (the user gets a horizontal scroll-bar
instead)
Sorry, but doesn’t work (a scroll-bar, yes, but the text is still wrapped).
As far as three things on the same line, you can have two left floats
(#logo, #slogan) and leave the right content in the main flow.
Myes, but I’d like a big enough gap between the floats. And specifying
an explicit margin/padding will give similar problems with small viewports.

Thanks anyway, H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Oct 10 '08 #3

Hendrik Maryns wrote:
>
if you make the viewport small, the
slogan text in the middle overlaps with the navigation buttons.

http://www.weltladen-tuebingen.de/

- instead of position:relative and top:1em (they belong together,
obviously, the one does nothing without the other), tried margin-top: 1
em, but that shifts the floats down as well.
Margins are subject to margin collapsing rules, which affects spacing of
elements around it. Margins and floats can be even trickier.
I do not really understand why
clear:both on the line doesn’t work as expected.
Relative positioning does not do what you probably think it does - it
offsets the element's position without affecting the other elements
around it. That's why the line doesn't shift down when the slogan line
wraps - it behaves as though slogan is staticly positioned.
http://brainjar.com/css/positioning/

Go back to static positioning on slogan, but try padding-top:1em instead
of margin-top, then you'll avoid the margin collapsing issues.

--
Berg
Oct 10 '08 #4
On Fri, 10 Oct 2008 15:19:43 +0200, Hendrik Maryns wrote:
David Stone schreef:
>In article <gc**********@newsserv.zdv.uni-tuebingen.de>,
Hendrik Maryns <gt*******@sneakemail.comwrote:
>>Hi,

There is a little problem with the header on the page I recently
converted from frames to proper HTML+CSS. The top part with the
navigation used to be the top frame but is now included via SSI. On a
broad screen, it looks good, but if you make the viewport small, the
slogan text in the middle overlaps with the navigation buttons.

http://www.weltladen-tuebingen.de/

I experimented with the following:
- put the slogan line between the floats. This results in the right
float being pushed down
- instead of position:relative and top:1em (they belong together,
obviously, the one does nothing without the other), tried margin-top: 1
em, but that shifts the floats down as well.

So what I want is that the slogan is nicely centered between the floats,
both vertically and horizontally, but that it doesn't overlap with the
line below if the viewport gets small. I do not really understand why
clear:both on the line doesn't work as expected. float: center;
would be the solution, but this doesn't exist.

You could set a min-width so that, if the viewport is shrunk, you don't
observe the behaviour (the user gets a horizontal scroll-bar instead)

Sorry, but doesn't work (a scroll-bar, yes, but the text is still
wrapped).
>As far as three things on the same line, you can have two left floats
(#logo, #slogan) and leave the right content in the main flow.

Myes, but I'd like a big enough gap between the floats. And
specifying an explicit margin/padding will give similar problems with
small viewports.

Thanks anyway, H.
It looks like your min-width would have to be about 1100px to get it so
the title doesn't wrap - which is too wide for most people.

I would play with the position-top of #slogan so you are able to fit two
lines of text there, and then you can go with a min-width of about 900
(which is still too wide for many people). It's too bad your address has
such a long line in it - perhaps you can break that up into two?

Oct 10 '08 #5
Bergamot schreef:
Hendrik Maryns wrote:
>if you make the viewport small, the
slogan text in the middle overlaps with the navigation buttons.

http://www.weltladen-tuebingen.de/

- instead of position:relative and top:1em (they belong together,
obviously, the one does nothing without the other), tried margin-top: 1
em, but that shifts the floats down as well.

Margins are subject to margin collapsing rules, which affects spacing of
elements around it. Margins and floats can be even trickier.
>I do not really understand why
clear:both on the line doesn’t work as expected.

Relative positioning does not do what you probably think it does - it
offsets the element's position without affecting the other elements
around it. That's why the line doesn't shift down when the slogan line
wraps - it behaves as though slogan is staticly positioned.
http://brainjar.com/css/positioning/

Go back to static positioning on slogan, but try padding-top:1em instead
of margin-top, then you'll avoid the margin collapsing issues.
That’s a valuable suggestion. It starts looking stupid for a very small
viewport, but that is because then the last word is on a line /below/
the floats, and the centering is changed. A trick would be to make the
floats bigger, by splitting the first address line, as edgy suggested,
and putting some padding around the logo (I think I’ll try to scale it
up with Gimp, but that’s for later).

Thanks all, H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Oct 10 '08 #6
Op 10-10-08 16:21 heeft Bergamot als volgt van zich laten horen:
Hendrik Maryns wrote:
>if you make the viewport small, the
slogan text in the middle overlaps with the navigation buttons.

http://www.weltladen-tuebingen.de/

- instead of position:relative and top:1em (they belong together,
obviously, the one does nothing without the other), tried margin-top: 1
em, but that shifts the floats down as well.

Margins are subject to margin collapsing rules, which affects spacing of
elements around it. Margins and floats can be even trickier.
>I do not really understand why
clear:both on the line doesn’t work as expected.

Relative positioning does not do what you probably think it does - it
offsets the element's position without affecting the other elements
around it. That's why the line doesn't shift down when the slogan line
wraps - it behaves as though slogan is staticly positioned.
http://brainjar.com/css/positioning/

Go back to static positioning on slogan, but try padding-top:1em instead
of margin-top, then you'll avoid the margin collapsing issues.
I’ve had a shot at it now, but there is still one problem: if the text
gets wrapped, the padding-top is no longer wanted. I want it to be
*vertically centered* between the two floats. Is there really no way to
achieve this?

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
www.lieverleven.be
http://catb.org/~esr/faqs/smart-questions.html
Oct 11 '08 #7

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

Similar topics

0
by: marius | last post by:
Hi! I'm currently trying to move from MS SQLServer to MySQL, running on windows XP. When trying to connect to mysql on localhost with mysql control center I get the 2013-error "Lost connection...
3
by: Mark Carroll | last post by:
I've been wanting web pages that nicely embed images among text. The way I typically do this at the moment is to sprinkle my IMGs through the text as floats, alternating between float: left and...
32
by: Axel Dahmen | last post by:
Hi, I've posted this question a few months ago but didn't get a truly satisfying answer then. So I'd like to post my question again: How can I center a DIV? The content in the DIV should be...
2
by: Dr. Richard E. Hawkins | last post by:
I've googled around, and asked everyone I know, but I still can't find any reference to anyone else having faced this particular IE bug with floats. I've put a page at...
2
by: sylvian stone | last post by:
Hi, I'm trying to do something that has always been easy with tables - namely use a three column layout, and above the main layout, show three images - one on the absolute left, one on the absolute...
7
by: Sean | last post by:
Hi, I have a tab control containing few tab pages. On each tab pages, I put an image on the tab page's title bar (the area on top of a tab page, ie where tooltip will appear). If i put both...
5
by: OtisUsenet | last post by:
Hi, I'm killing myself trying to get a "horizontal nav bar" where some text is left aligned, and some is aligned to the right, kind of like this: LEFT ...
2
by: David | last post by:
I'm trying to style a kind of minimalist welcome page where each of X number of (gray?) boxes will be links to a part of the site. I want to implement the navbar (ie, set of boxes linking to...
11
by: Mike Harrison | last post by:
Hi, I have some simple HTML like this: <div id="container" style="width:100%;"> <input type="text" <input type="button" style="float:right;" value="Click here..."> </div> I want the button...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.