css

Vertical align two columns, a shorter and a longer text  #angularjs #reactjs

  • The first solution is almost working, I have to keep the shortest line of text on one line though, but I forgot to say it before.
  • #container { overflow: hidden; } #DivA { overflow: hidden; background: #ccc; float:left; width:90%; } #DivB { background: #000; color: #FFF; float:left; width:10%; word-wrap:break-word; }
    Just another text.
    Lots and lots of text.
  • To have the shorter div display all the text on the same line, all you need to do is add white-space: nowrap; to it.
  • Well, it just needs to keep its dimension, and the other text continue to shrtink.
  • Even if percentual, you fixed a width, it will not work for my problem as stated in the question – Andrea 22 mins ago

I’ve tried in many ways to vertical align the shorter text with the longer one keeping everything responsive but I can’t seem to find a valid solution.

@ng_real_ninja: Vertical align two columns, a shorter and a longer text #angularjs #reactjs

here is a simplified fiddle of what I’m working on:

HTML:

Just another text.
Lots and lots of text. Lots and lots of text.Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text.

CSS:

#container { overflow: hidden; } #DivA { overflow: hidden; background: #ccc; } #DivB { float: right; background: #000; color: #FFF; }

I’ve tried in many ways to vertical align the shorter text with the longer one keeping everything responsive but I can’t seem to find a valid solution.

All the similar questions I found use something not dynamic, let’s say a fixed width, height, margin or anything else, and these solutions won’t work for my problem. Thanks!

Edit: Sorry, I forgot to write that the shorter line still needs to keep its size like in the example I posted, the longer text needs to shrink besides it while it stays still

The first solution is almost working, I have to keep the shortest line of text on one line though, but I forgot to say it before. Well, it just needs to keep its dimension, and the other text continue to shrtink. I missed this important information because my fiddle already did that, sorry. – Andrea 29 mins ago

Just another text.
Lots and lots of text. Lots and lots of text.Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text.

Okay @Andrea, you got a solution that works. – frnt 6 mins ago

Sorry, but I missed something initally in my question, I have to keep the shortest line of text on one line. Well, it just needs to keep its dimension, and the other text continue to shrink. I missed this important information because my fiddle already did that, sorry. – Andrea 26 mins ago

css

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.