Programing

div에 스크롤 막대를 어떻게 추가합니까?

lottogame 2020. 11. 11. 07:51
반응형

div에 스크롤 막대를 어떻게 추가합니까?


일부 결과를 표시하는 팝업이 있고 결과가 잘려서 스크롤 막대가 표시되기를 원합니다 (팝업이 너무 길지 않기를 원합니다).


style="overflow-y:scroll;"div 태그 에 추가해야합니다 . (이렇게하면 수직으로 스크롤바가 강제로 표시됩니다).

필요할 때만 스크롤바를 원하면 overflow-y:auto;


스크롤로 멋진 Div를 갖는 CSS 클래스

.DivToScroll{   
    background-color: #F5F5F5;
    border: 1px solid #DDDDDD;
    border-radius: 4px 0 4px 0;
    color: #3B3C3E;
    font-size: 12px;
    font-weight: bold;
    left: -1px;
    padding: 10px 7px 5px;
}

.DivWithScroll{
    height:120px;
    overflow:scroll;
    overflow-x:hidden;
}

jquery를 사용하여 스크롤 막대를 추가하려면 다음이 작동합니다. div의 id가 'mydiv'인 경우 css 속성이있는 다음 jquery id 선택기를 사용할 수 있습니다.

jQuery('#mydiv').css("overflow-y", "scroll");

<div class="scrollingDiv">foo</div> 

div.scrollingDiv
{
   overflow:scroll;
}

<head>
<style>
div.scroll
{
background-color:#00FFFF;
width:40%;
height:200PX;
FLOAT: left;
margin-left: 5%;
padding: 1%;
overflow:scroll;
}


</style>
</head>

<body>



<div class="scroll">You can use the overflow property when you want to have better       control of the layout. The default value is visible.better control of the layout. The default value is visible.better control of the layout. The default value is visible.better control of the layout. The default value is visible.better control of the layout. The default value is visible.better control of the layout. The default value is visible.better </div>


</body>
</html>

참고 URL : https://stackoverflow.com/questions/2836827/how-do-you-add-a-scroll-bar-to-a-div

반응형