Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Float objects and page directon

Featured Replies

Hi all,

 

I am facing a difficult problem. In short I have the following html code

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
</head>
<body style="direction: ltr">
<div style="border-style: solid; width: 150px; height: 150px;">
	<p>
		hello
	</p>
</div>
<div style="border-style: solid; width: 150px; height: 150px; float: right;">
	<p>
		to you
	</p>
</div>
</body>
</html>

 

This html will display two divs with borders, on the left and the other is floating to the right. Notice that the page direction is ltr. If I change the page direction to rtl then the first div will be aligned based on the direction while the floating div will remain in its place. I need it to align to the left since the page direction has changed. I can do this by using a javascript that will traverse some classes with the float element and then change it based on the page direction, but I need more generic way to handle this problem. Can anyone give me a solution or a hint?

If you float both divs left? what happens then? they reverse the order? I always thought ltr and rtl just determined content flow, not document flow.

 

*shrugs*

 

Your explanation is a little difficult to understand, but i think i know what you mean, can you not just float both divs left? so they're floating one beside the other? or will it switch them around?

  • Author

OK, let me explain it in more details

 

The code snippet above will generate a page like the following:

 

2wggchd.jpg

 

 

When I change the direction of the page to "rtl" you can logically assume that the resulting page will become something like this:

 

mcrr68.jpg

 

But the actual page when changing the direction to "rtl" for the snippet above is:

1zmczrt.jpg

 

This problem is cased by div 2 since it is floating to the right. The browser should respect the context in which the float direction is, but it is not doing so.

Any idea on how to fix this issue?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.