Align text around an image floated to the right
up vote
0
down vote
favorite
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:
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
add a comment |
up vote
0
down vote
favorite
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:
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
Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w
– isherwood
Nov 19 at 21:34
1
Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)
– isherwood
Nov 19 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 at 21:41
I'd assume that the question would've mentioned it were that the case. Maybe not.
– isherwood
Nov 19 at 21:42
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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:
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
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:
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
html css
edited Nov 19 at 21:28
asked Nov 19 at 21:23
wtreston
577213
577213
Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w
– isherwood
Nov 19 at 21:34
1
Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)
– isherwood
Nov 19 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 at 21:41
I'd assume that the question would've mentioned it were that the case. Maybe not.
– isherwood
Nov 19 at 21:42
add a comment |
Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w
– isherwood
Nov 19 at 21:34
1
Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)
– isherwood
Nov 19 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 at 21:41
I'd assume that the question would've mentioned it were that the case. Maybe not.
– isherwood
Nov 19 at 21:42
Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w
– isherwood
Nov 19 at 21:34
Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w
– isherwood
Nov 19 at 21:34
1
1
Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)
– isherwood
Nov 19 at 21:36
Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)
– isherwood
Nov 19 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 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 at 21:41
I'd assume that the question would've mentioned it were that the case. Maybe not.
– isherwood
Nov 19 at 21:42
I'd assume that the question would've mentioned it were that the case. Maybe not.
– isherwood
Nov 19 at 21:42
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
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>
Is there anyway of doing this without having words overflow onto the next line?
– wtreston
Nov 19 at 21:40
changed it toword-break: break-word;
. Thanks
– wtreston
Nov 19 at 21:42
@wtreston Oh, but be careful,word-break: break-word
doesn't work in all browsers. You can useword-break: break-all; word-break: break-word;
for a fallback.
– Mr Lister
Nov 19 at 21:45
Ok thank you. I will use that!
– wtreston
Nov 19 at 21:46
add a comment |
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',
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
up vote
1
down vote
accepted
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>
Is there anyway of doing this without having words overflow onto the next line?
– wtreston
Nov 19 at 21:40
changed it toword-break: break-word;
. Thanks
– wtreston
Nov 19 at 21:42
@wtreston Oh, but be careful,word-break: break-word
doesn't work in all browsers. You can useword-break: break-all; word-break: break-word;
for a fallback.
– Mr Lister
Nov 19 at 21:45
Ok thank you. I will use that!
– wtreston
Nov 19 at 21:46
add a comment |
up vote
1
down vote
accepted
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>
Is there anyway of doing this without having words overflow onto the next line?
– wtreston
Nov 19 at 21:40
changed it toword-break: break-word;
. Thanks
– wtreston
Nov 19 at 21:42
@wtreston Oh, but be careful,word-break: break-word
doesn't work in all browsers. You can useword-break: break-all; word-break: break-word;
for a fallback.
– Mr Lister
Nov 19 at 21:45
Ok thank you. I will use that!
– wtreston
Nov 19 at 21:46
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
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>
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>
answered Nov 19 at 21:35
Mr Lister
34.3k1072113
34.3k1072113
Is there anyway of doing this without having words overflow onto the next line?
– wtreston
Nov 19 at 21:40
changed it toword-break: break-word;
. Thanks
– wtreston
Nov 19 at 21:42
@wtreston Oh, but be careful,word-break: break-word
doesn't work in all browsers. You can useword-break: break-all; word-break: break-word;
for a fallback.
– Mr Lister
Nov 19 at 21:45
Ok thank you. I will use that!
– wtreston
Nov 19 at 21:46
add a comment |
Is there anyway of doing this without having words overflow onto the next line?
– wtreston
Nov 19 at 21:40
changed it toword-break: break-word;
. Thanks
– wtreston
Nov 19 at 21:42
@wtreston Oh, but be careful,word-break: break-word
doesn't work in all browsers. You can useword-break: break-all; word-break: break-word;
for a fallback.
– Mr Lister
Nov 19 at 21:45
Ok thank you. I will use that!
– wtreston
Nov 19 at 21:46
Is there anyway of doing this without having words overflow onto the next line?
– wtreston
Nov 19 at 21:40
Is there anyway of doing this without having words overflow onto the next line?
– wtreston
Nov 19 at 21:40
changed it to
word-break: break-word;
. Thanks– wtreston
Nov 19 at 21:42
changed it to
word-break: break-word;
. Thanks– wtreston
Nov 19 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 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 at 21:45
Ok thank you. I will use that!
– wtreston
Nov 19 at 21:46
Ok thank you. I will use that!
– wtreston
Nov 19 at 21:46
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Your markup works as-is. Can you reproduce the problem? jsfiddle.net/isherwood/c8mabv5w
– isherwood
Nov 19 at 21:34
1
Maybe you should use Lorem Ipsum text rather than absurdly long non-words for testing. :)
– isherwood
Nov 19 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 at 21:41
I'd assume that the question would've mentioned it were that the case. Maybe not.
– isherwood
Nov 19 at 21:42