Align text around an image floated to the right












0















I am trying to get an image to appear in the top right corner of a div, with text first to the left of the image, and then when the image ends, the text should take up the full width of the div.



This is currently what is output:



enter image description here



This is the html:



<div>
<img src="./images/gym.jpeg" class="pic2"/>
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>


and this the css:



.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}


I have tried the solutions here however they have not worked for me, and give the same output as the image shown



Thanks for any help










share|improve this question

























  • Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w

    – isherwood
    Nov 19 '18 at 21:34






  • 1





    Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)

    – isherwood
    Nov 19 '18 at 21:36











  • @isherwood So your solution would be to use shorter words? Yes, that would work as well. I assumed that the long words were there for a reason though...

    – Mr Lister
    Nov 19 '18 at 21:41











  • I'd assume that the question would've mentioned it were that the case. Maybe not.

    – isherwood
    Nov 19 '18 at 21:42
















0















I am trying to get an image to appear in the top right corner of a div, with text first to the left of the image, and then when the image ends, the text should take up the full width of the div.



This is currently what is output:



enter image description here



This is the html:



<div>
<img src="./images/gym.jpeg" class="pic2"/>
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>


and this the css:



.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}


I have tried the solutions here however they have not worked for me, and give the same output as the image shown



Thanks for any help










share|improve this question

























  • Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w

    – isherwood
    Nov 19 '18 at 21:34






  • 1





    Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)

    – isherwood
    Nov 19 '18 at 21:36











  • @isherwood So your solution would be to use shorter words? Yes, that would work as well. I assumed that the long words were there for a reason though...

    – Mr Lister
    Nov 19 '18 at 21:41











  • I'd assume that the question would've mentioned it were that the case. Maybe not.

    – isherwood
    Nov 19 '18 at 21:42














0












0








0








I am trying to get an image to appear in the top right corner of a div, with text first to the left of the image, and then when the image ends, the text should take up the full width of the div.



This is currently what is output:



enter image description here



This is the html:



<div>
<img src="./images/gym.jpeg" class="pic2"/>
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>


and this the css:



.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}


I have tried the solutions here however they have not worked for me, and give the same output as the image shown



Thanks for any help










share|improve this question
















I am trying to get an image to appear in the top right corner of a div, with text first to the left of the image, and then when the image ends, the text should take up the full width of the div.



This is currently what is output:



enter image description here



This is the html:



<div>
<img src="./images/gym.jpeg" class="pic2"/>
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>


and this the css:



.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}


I have tried the solutions here however they have not worked for me, and give the same output as the image shown



Thanks for any help







html css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 21:28







wtreston

















asked Nov 19 '18 at 21:23









wtrestonwtreston

577213




577213













  • Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w

    – isherwood
    Nov 19 '18 at 21:34






  • 1





    Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)

    – isherwood
    Nov 19 '18 at 21:36











  • @isherwood So your solution would be to use shorter words? Yes, that would work as well. I assumed that the long words were there for a reason though...

    – Mr Lister
    Nov 19 '18 at 21:41











  • I'd assume that the question would've mentioned it were that the case. Maybe not.

    – isherwood
    Nov 19 '18 at 21:42



















  • Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w

    – isherwood
    Nov 19 '18 at 21:34






  • 1





    Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)

    – isherwood
    Nov 19 '18 at 21:36











  • @isherwood So your solution would be to use shorter words? Yes, that would work as well. I assumed that the long words were there for a reason though...

    – Mr Lister
    Nov 19 '18 at 21:41











  • I'd assume that the question would've mentioned it were that the case. Maybe not.

    – isherwood
    Nov 19 '18 at 21:42

















Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w

– isherwood
Nov 19 '18 at 21:34





Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w

– isherwood
Nov 19 '18 at 21:34




1




1





Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)

– isherwood
Nov 19 '18 at 21:36





Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)

– isherwood
Nov 19 '18 at 21:36













@isherwood So your solution would be to use shorter words? Yes, that would work as well. I assumed that the long words were there for a reason though...

– Mr Lister
Nov 19 '18 at 21:41





@isherwood So your solution would be to use shorter words? Yes, that would work as well. I assumed that the long words were there for a reason though...

– Mr Lister
Nov 19 '18 at 21:41













I'd assume that the question would've mentioned it were that the case. Maybe not.

– isherwood
Nov 19 '18 at 21:42





I'd assume that the question would've mentioned it were that the case. Maybe not.

– isherwood
Nov 19 '18 at 21:42












1 Answer
1






active

oldest

votes


















1














What you need to for the words to be breakable everywhere. So, word-break: break-all;






.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}

div { /* new */
word-break: break-all;
}

<div>
<img src="https://placehold.it/400x150" class="pic2" /> slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>








share|improve this answer
























  • Is there anyway of doing this without having words overflow onto the next line?

    – wtreston
    Nov 19 '18 at 21:40











  • changed it to word-break: break-word;. Thanks

    – wtreston
    Nov 19 '18 at 21:42











  • @wtreston Oh, but be careful, word-break: break-word doesn't work in all browsers. You can use word-break: break-all; word-break: break-word; for a fallback.

    – Mr Lister
    Nov 19 '18 at 21:45











  • Ok thank you. I will use that!

    – wtreston
    Nov 19 '18 at 21:46











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382836%2falign-text-around-an-image-floated-to-the-right%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














What you need to for the words to be breakable everywhere. So, word-break: break-all;






.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}

div { /* new */
word-break: break-all;
}

<div>
<img src="https://placehold.it/400x150" class="pic2" /> slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>








share|improve this answer
























  • Is there anyway of doing this without having words overflow onto the next line?

    – wtreston
    Nov 19 '18 at 21:40











  • changed it to word-break: break-word;. Thanks

    – wtreston
    Nov 19 '18 at 21:42











  • @wtreston Oh, but be careful, word-break: break-word doesn't work in all browsers. You can use word-break: break-all; word-break: break-word; for a fallback.

    – Mr Lister
    Nov 19 '18 at 21:45











  • Ok thank you. I will use that!

    – wtreston
    Nov 19 '18 at 21:46
















1














What you need to for the words to be breakable everywhere. So, word-break: break-all;






.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}

div { /* new */
word-break: break-all;
}

<div>
<img src="https://placehold.it/400x150" class="pic2" /> slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>








share|improve this answer
























  • Is there anyway of doing this without having words overflow onto the next line?

    – wtreston
    Nov 19 '18 at 21:40











  • changed it to word-break: break-word;. Thanks

    – wtreston
    Nov 19 '18 at 21:42











  • @wtreston Oh, but be careful, word-break: break-word doesn't work in all browsers. You can use word-break: break-all; word-break: break-word; for a fallback.

    – Mr Lister
    Nov 19 '18 at 21:45











  • Ok thank you. I will use that!

    – wtreston
    Nov 19 '18 at 21:46














1












1








1







What you need to for the words to be breakable everywhere. So, word-break: break-all;






.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}

div { /* new */
word-break: break-all;
}

<div>
<img src="https://placehold.it/400x150" class="pic2" /> slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>








share|improve this answer













What you need to for the words to be breakable everywhere. So, word-break: break-all;






.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}

div { /* new */
word-break: break-all;
}

<div>
<img src="https://placehold.it/400x150" class="pic2" /> slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>








.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}

div { /* new */
word-break: break-all;
}

<div>
<img src="https://placehold.it/400x150" class="pic2" /> slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>





.description {
padding: 0% 2% 1% 2%;
}

.description p {
font-size: 20px;
}

.pic2 {
float: right;
}

div { /* new */
word-break: break-all;
}

<div>
<img src="https://placehold.it/400x150" class="pic2" /> slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL slasdfkasjhdfkjasdhfkjlasdhfkjlashdfkjlshdKL
</div>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 '18 at 21:35









Mr ListerMr Lister

34.7k1074117




34.7k1074117













  • Is there anyway of doing this without having words overflow onto the next line?

    – wtreston
    Nov 19 '18 at 21:40











  • changed it to word-break: break-word;. Thanks

    – wtreston
    Nov 19 '18 at 21:42











  • @wtreston Oh, but be careful, word-break: break-word doesn't work in all browsers. You can use word-break: break-all; word-break: break-word; for a fallback.

    – Mr Lister
    Nov 19 '18 at 21:45











  • Ok thank you. I will use that!

    – wtreston
    Nov 19 '18 at 21:46



















  • Is there anyway of doing this without having words overflow onto the next line?

    – wtreston
    Nov 19 '18 at 21:40











  • changed it to word-break: break-word;. Thanks

    – wtreston
    Nov 19 '18 at 21:42











  • @wtreston Oh, but be careful, word-break: break-word doesn't work in all browsers. You can use word-break: break-all; word-break: break-word; for a fallback.

    – Mr Lister
    Nov 19 '18 at 21:45











  • Ok thank you. I will use that!

    – wtreston
    Nov 19 '18 at 21:46

















Is there anyway of doing this without having words overflow onto the next line?

– wtreston
Nov 19 '18 at 21:40





Is there anyway of doing this without having words overflow onto the next line?

– wtreston
Nov 19 '18 at 21:40













changed it to word-break: break-word;. Thanks

– wtreston
Nov 19 '18 at 21:42





changed it to word-break: break-word;. Thanks

– wtreston
Nov 19 '18 at 21:42













@wtreston Oh, but be careful, word-break: break-word doesn't work in all browsers. You can use word-break: break-all; word-break: break-word; for a fallback.

– Mr Lister
Nov 19 '18 at 21:45





@wtreston Oh, but be careful, word-break: break-word doesn't work in all browsers. You can use word-break: break-all; word-break: break-word; for a fallback.

– Mr Lister
Nov 19 '18 at 21:45













Ok thank you. I will use that!

– wtreston
Nov 19 '18 at 21:46





Ok thank you. I will use that!

– wtreston
Nov 19 '18 at 21:46


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382836%2falign-text-around-an-image-floated-to-the-right%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?