1

Is there a simple way to dynamically indent each line of a block of text inside a div? I want the text to conform to the oddly shaped div I made. Example: enter image description here

asked Feb 13, 2015 at 22:13
4
  • So much as I know, css has no idea about the concept of a "line" - You can wrap specific lines of text in tags, like span, and set nth-child rules for them. Commented Feb 13, 2015 at 22:17
  • 2
    Provide the html you have. It will help to see what your attempting. Commented Feb 13, 2015 at 22:24
  • I'm going to say, short answer, this is not possible, but you could possibly (though I can't think of a way) use some tricky javascript to do it. All I can suggest is a div per line with stacked <dd> tags to push out the indent with each line. Commented Feb 13, 2015 at 22:37
  • 1
    I tried something here, maybe it can help. here is jsfiddle link Commented Feb 13, 2015 at 23:07

2 Answers 2

2

This won't work in all cases but something you could do if you wanted to have sloping indents is play with the css transform attribute.

I have made a js fiddle to illustrate...

http://jsfiddle.net/ycvqqxg4/10/

Edited fiddle.

div.indenting-text{
 transform: skewX(15deg);
 font-style: italic;
}

enjoy :)

EDIT:

I've gone back into the js fiddle and improved it to use a different method than the one i mentioned above. This way makes use of a div with its 'shape-outside' set to a sloped polygon so that css naturally wraps the text around the slope instead of it being jimmy rigged by css in the previous version.

here is the js fiddle

http://jsfiddle.net/ycvqqxg4/15/

answered Feb 14, 2015 at 18:05
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Zezilp! This really helps! I am thinking maybe I will make a custom font. My boss is kinda weird tho... So we will see. But this is probably the closest solution.
1

You could take a look at wrapping text around images, which can be done with circular images and such, like this example shows

http://demosthenes.info/blog/916/Wrapping-Text-Around-Circular-Images-With-CSS-Shapes

I think it'll give you a nicer effect. You might have to create a blank image template or something though.

answered Feb 14, 2015 at 19:00

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.