8

For some reason when I combine columns and overflow-y: scroll or auto, the scroll is horizontal instead of vertical. Here's the code:

.list {
  -webkit-column-count: 3;
  -moz-column-count: 3;
  column-count: 3;
  -webkit-column-gap: 5px;
  -moz-column-gap: 5px;
  column-gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}

I've also tried using overflow-x, removing the column gap and using padding instead, nothing seems to work.

4
  • Please build a mcve. There's a snippet tool for that in SO Commented Apr 8, 2016 at 15:19
  • Please provide a working code snippet and not just a fragment Commented Apr 8, 2016 at 15:19
  • With only one css class, we can't help much. If you create a minimal verifiable example of your problem using a code snippet on SO or a place like jsfiddle, folks will be able to see what you're talking about and help you faster. Commented Apr 8, 2016 at 15:21
  • Welcome to SO. Just in case you don't know what Denys meant by "mcve" , here is a reference for you: How to create a Minimal, Complete, and Verifiable example. Commented Apr 8, 2016 at 15:21

1 Answer 1

10

Based on what is said about the height in the MDN documentation, I don't think this is something that can be done directly from .list. Instead, one solution is to wrap .list in a short div.

Take a look:

.list {
  -webkit-column-count: 3;
  -moz-column-count: 3;
  column-count: 3;
  -webkit-column-gap: 5px;
  -moz-column-gap: 5px;
  column-gap: 5px;
  max-height: 1000px;
}

.list-contain {
  height: 200px;
  overflow-y: scroll;
}

/* to prevent more scrolling in snippet */
body {
  margin: 0;
  padding: 0;
}
<div class="list-contain">


  <div class="list">
    "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human
    happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues
    or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except
    to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" Other translation: "On the other hand,
    we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs
    to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when
    nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have
    to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."
  </div>
</div>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.