2016-04-08 8 views
3

何かの理由で、列とoverflow-yを組み合わせると、スクロールまたは自動、スクロールは垂直ではなく水平です。私はまた、カラムギャップを除去して、何も動いていないようにみえ代わりに、パディングを使用して、オーバーフロー-Xを使用してみましたCSS列+オーバーフロー-yスクロールの問題

.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; 
} 

:ここでは、コードです。

+0

を。 [SOのためのスニペットツール](https://blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/) –

+0

作業用のコードスニペットを入力してください。フラグメントだけでなく、 – LGSon

+0

1つのCSSクラスで、私たちはあまり役に立たない。 SOやjsfiddleのような場所でコードスニペットを使用して、問題の最小限の検証可能な例を作成すると、人々はあなたが話していることを見て、より速く手伝うことができます。 – Hypaethral

答えて

2

MDN documentationの高さについて言えば、これは.listから直接行うことはできません。代わりに、短いdivに.listをラップする方法があります。

見てください:[MCVE](http://stackoverflow.com/help/mcve)を構築してください

.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>

関連する問題