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.

Div Overlapping Content - How do I stop it?

Featured Replies

Hello All

 

Question 1:

Really frustrating this one as I feel that I should be able to solve this as its a bit of newbie prob, but I've tried messing about with the clear:both and content: " "; and I can't seem to effect a change.

 

Essentially the problem is that one of my paragraphs of text jumps up overlapping another paragraph of text. I cannot set these paragraphs to fixed sizes cos they pull the info from a database and also because the website is responsive/elastic.

 

Its the first and second paragraphs of body text on this page:

 

http://www.mason-uk.co.uk/responsive/html5boilerplate5-contactpage.asp

 

 

Question 2:

Also it would be cool if the bolder first paragraph of text could also wrap around the bottom of the image (if there is enough text there to do it). Is there a simple way of doing that?

 

Many Thanks!

For the first issue, you can resolve it by removing the float:none and the top position from .toptext. So it's from this:

 

.toptext {
top: 130px;
float: none;
display: block;
height: 100%;
} 

To this:

 

.toptext {
display: block;
height: 100%;
} 

For the second issue, I'm not sure it's possible unless the image is within the same container as the text. But I could be wrong.

 

Lyndsey.

  • Author

Thanks Lyndsey, That solved my first question but has created a knock on problem:

the text now jumps down beneath the picture and is not next to it...

Ah sorry! In that case, why not try putting the element back to its original state but having a padding bottom to push the text down?

 

At the moment, this code seems to work, but the 'to contact Mason...' text is pushed a bit too far downwards:

@media only screen and (min-width: 1140px) {
.toptext, .textspan p {
    font-size: 14px;
    margin-bottom: 10px;
    float: none;
    top: 130px;
    }
}

 

Are you updating right now? Could be why it's changing for me.

 

Edit. Try this:

 

.toptext {
float: none;
display: block;
top: 130px;
padding-bottom: 150px;
}

Exactly what Lyndsey said. You're positioning the p in such a way that depending on it's length it will pop out of its container. But yes, removing those two properties breaks the layout you're going for so you might have to play around or maybe restructure that section.

 

I may be able to play around with that.

 

As for your second question; yes, that's extremely easy to do. It's actually what floats were added to CSS for. Here is a super simple demo I just made: http://codepen.io/HeyDanReeves/pen/Jnbqx

  • Author

Yes was fiddling with it a bit just now. So are you saying that the original code I had for my CSS should be re-instated and then add padding?

Yes, reinstating the code with added padding worked for me. But maybe heydanreeves has a better idea? I'm not sure if this is the correct way, although it works.

  • Author

Thanks Again Lyndsey, it did sort of work, It looks ok on that page, but has thrown it out on another page...

 

The problem is making this code robust enough to deal with different sized pics and quantities of text.

Cos this website draws itself from a large Database and I don't know how much text there will or wont be on any given entry (or the exact dimensions of a image), plus the responsive aspect, it makes it a bit tricky with things like this.

 

 

Other Page That it Has Thrown it Out on:

http://www.mason-uk.co.uk/responsive/html5boilerplate5-productpage.html

 

Current Page Again:

http://www.mason-uk.co.uk/responsive/html5boilerplate5-contactpage.asp

 

 

Thanks for your response HeydanReeves, Please let me know other ways to restructure this area, I'm bamboozled at the moment

PS

Just looking at your code demo now and seeing whether I can incorporate that into this design somehow, although not sure how it will work at the lower resolutions with the responsive design, gonna give it a bash! Thanks!

Edited by AblazeRich

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.