Solved

floating image after text even when the text wraps

Posted on 2014-01-08
2
188 Views
Last Modified: 2014-01-15
Hi,

I need an image to float right of a headline even when the text in the headline wraps onto another line.

<div style="width:100px">
<h3 style="float: left">headline text</h3>
<span stlye="float:left">background image placeholder</span>
</div>

At the moment I am having issues if the text wraps onto a new line the image no longer sits to the right of the text but instead sits underneath it. If the text is in one line it looks fine.

Thanks


Attached is a schematic example of what I need
example.jpg
0
Comment
Question by:Al4ddin2
2 Comments
 
LVL 8

Accepted Solution

by:
Adrian Crabtree earned 250 total points
Comment Utility
Hi Al4ddin2, you can try setting the H3 to a display: inline. Here's a pen I created to illustrate that idea.

http://codepen.io/anon/pen/Dykuh
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 total points
Comment Utility
Since you are setting the container to width:100px there is no room for the image to float next to the text. An inline element will take up as much room as it needs - in this case the whole 100px before wrapping.
To get them on the same line you need to give the H3 tag a set width that allows enough room for the image to fit into the remaining width of the container
e.g.
http://jsfiddle.net/b9MCs/4/
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
spacing 5 25
Problem to picture file 3 37
A page to have its own footer separate from the other pages 3 18
Css issue on scroll 1 17
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now