span 또는 div 래핑 방지
div
고정 너비 의 요소 그룹을 컨테이너에 넣고 가로 스크롤 막대를 표시 하고 싶습니다 . div
/의 span
요소는, HTML (기본적으로 미개봉)에 나타나는 순서대로 왼쪽에서 오른쪽으로, 한 줄에 표시됩니다.
이렇게하면 가로 스크롤 막대가 나타나고 세로 스크롤 막대 대신 콘텐츠를 읽는 데 사용할 수 있습니다 (왼쪽에서 오른쪽으로).
컨테이너에 플로팅 한 다음 컨테이너에 white-space: nowrap
스타일을 적용하려고했지만 슬프게도 여전히 랩으로 보입니다.
아이디어?
다음과 같이 보였습니다 :
.slideContainer {
white-space: nowrap;
}
.slide {
width: 800px;
float: left;
display: inline;
}
<div class="slideContainer">
<div class="slide">Some content</div>
<div class="slide">More content</div>
<div class="slide">Even More content!</div>
</div>
업데이트 : 예를 들어 사이트 를
참조 하지만 다른 방법이 아닌 것에 대해서는 잘못되었습니다-기사가 오래되었다고 확신합니다.
이 시도:
.slideContainer {
overflow-x: scroll;
white-space: nowrap;
}
.slide {
display: inline-block;
width: 600px;
white-space: normal;
}
<div class="slideContainer">
<span class="slide">Some content</span>
<span class="slide">More content. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
<span class="slide">Even more content!</span>
</div>
.slideContainer { overflow-x: scroll; }
(이를 읽을 때 브라우저가 지원하거나 지원하지 않을 수 있음) 생략 할 수 있으며이 컨테이너 대신 창에 스크롤 막대가 나타납니다.
여기서 핵심은 display: inline-block
입니다. 요즘에는 브라우저 간 지원 이 적절 하지만 평소와 같이 모든 대상 브라우저에서 테스트해야합니다.
그것은 단지 이것과 함께 작동합니다 :
.slideContainer {
white-space: nowrap;
}
.slide {
display: inline-block;
width: 600px;
white-space: normal;
}
나는 원래 가지고 float : left;
있었고 그것이 제대로 작동하지 못하게했습니다.
이 솔루션을 게시 해 주셔서 감사합니다.
트위터의 같은 것을 사용하는 경우 특히 부트 스트랩을 , white-space: nowrap;
아이에 패딩이나 마진을 적용 할 때 항상 CSS에서 작동하지 않습니다 div
. 그러나 border: 20px solid transparent;
패딩 / 여백 대신 동등한 스타일을 추가하면 일관되게 작동합니다.
언급했듯이 다음을 사용할 수 있습니다.
overflow: scroll;
If you only want the scroll bar to appear when necessary, you can use the "auto" option:
overflow: auto;
I don't think you should be using the "float" property with "overflow", but I'd have to try out your example first.
Looks like divs will not go outside of their body's width. Even within another div.
I threw this up to test (without a doctype though) and it does not work as thought.
.slideContainer {
overflow-x: scroll;
}
.slide {
float: left;
}
<div class="slideContainer">
<div class="slide" style="background: #f00">Some content Some content Some content Some content Some content Some content</div>
<div class="slide" style="background: #ff0">More content More content More content More content More content More content</div>
<div class="slide" style="background: #f0f">Even More content! Even More content! Even More content!</div>
</div>
What i am thinking is that the inner div's could be loaded through an iFrame, since that is another page and its content could be very wide.
참고URL : https://stackoverflow.com/questions/679804/prevent-wrapping-of-span-or-div
'Programing' 카테고리의 다른 글
동적으로 작성된 입력에 대해 jQuery .on ( 'change', function () {}이 트리거되지 않음 (0) | 2020.06.25 |
---|---|
Selenium Webdriver가 백그라운드에서 자동으로 브라우저 창을 열 수 있습니까? (0) | 2020.06.25 |
녹아웃 JS가있는 TypeScript (0) | 2020.06.24 |
C에서 열거 형의 크기는 얼마입니까? (0) | 2020.06.24 |
HTML 요소에 대한 브라우저의 기본 CSS (0) | 2020.06.24 |