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.

Very Simple CSS Question

Featured Replies

hey experts,



i've got a very simple css question.


this is what I have put together. my goal is, to have floatign elements so the design can be responsive to the screen size.



<style type="text/css" media="screen">

.float1 { float: left; width: 240px; }

.float2 { float: left; width: 240px; }

.float3 { float: left; width: 12px; margin-bottom: 1em; }

</style>

<div class="float1">
 text menüpunkte, etc. </div>


<div class="float2">


<img src="bild.jpg" border="0" alt="" width="268" height="177" />

</div>





following issues with that:


its working, but if the screen is big enough, the thext that comes unter
those elements continues on the right side. i want it to continue UNTER
it.



also, the text is sitting a bit lower than the picture.



please advice.



thanks!

You will need to clear the floats.

Add a clear propperty to the first element after the floating elements with a value of "left" or "both" to make sure it stays below.

  • Author

okay, ive tried to add a bunch of clearing commands in there which dont seem to work

<style type="text/css" media="screen">

.clearing { clear: both; }
.selector1 {
.clearing { clear: both; }
width:500px;
}
.float1 { float: left; width: 250px; }
.float2 { float: left; width: 250px; }
.clearing { clear: both; }

 

 

 

 

<br style="clear:both;"> at the end of the text in the second box also dont seem to do the trick

  • Author

still the image is too low. want it to be on line with the text

 

tried to put it in a table as well as use the align="top" command

 

<div class="float2">

<table>
<tr>
<td align="top">
<img src="images/FS.jpg" border="0" alt="" width="250" align="top"/>
</td>
</tr>
</table>

Edited by bigisbeautiful

Why not just use a clearfix?

 

I like to use the micro-clearfix

 

to use it you place class="cf" to the containing element

 

<div class="cf">
  <div class="float1">
 text menüpunkte, etc. </div>
  <div class="float2">

    <img src="bild.jpg" border="0" alt="" width="268" height="177" />
  </div>
</div>

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.