2017-06-22 36 views

回答

0

你可以欺騙,通過從.wrap刪除overflow: auto和增加額外的覆蓋隱藏溢出的內容:

https://codepen.io/anon/pen/PjjBxE

+0

thx。但1px的差距仍然存在:)可能你有什麼想法? http://i.imgur.com/uEAt4TW.png – DTXqueque

+0

@DTXqueque檢查是否還有差距:https://codepen.io/anon/pen/NggOyR –

1

你可以用一個面具,讓身體溢出:https://codepen.io/gc-nomade/pen/jwwpXQ

.wrap { 
 
    height: 80vh; 
 
    margin: 10vh 10vw; 
 
    width: 80vw; 
 
} 
 

 
.wrap:before {/* here comes the mask hidding edges with a white shadow */ 
 
    content: ""; 
 
    position: fixed; 
 
    top: 10vh; 
 
    bottom: 10vh; 
 
    left: 10vw; 
 
    width: 80vw; 
 
    border: solid 1px; 
 
    box-shadow: 0 0 0 10vw white; 
 
    pointer-events: none;/* will not catch pointer-events and will let pointer-events occurs within .wrap */ 
 
} 
 

 
.sidebar { 
 
    text-align: center; 
 
    background: rgba(170, 170, 170, 0.7); 
 
    height: 80vh; 
 
    position: fixed; 
 
    width: 20vw; 
 
    left: 10vw; 
 
} 
 

 
.sidebar button { 
 
    margin: 5px; 
 
} 
 

 
main { 
 
    background: #FFAB91; 
 
    margin-left: 20vw; 
 
} 
 

 
header { 
 
    background: #ccc; 
 
    height: 30px; 
 
    text-align: center; 
 
} 
 

 
header span { 
 
    background: #aaa; 
 
    display: inline-block; 
 
    height: 12px; 
 
    margin-top: 9px; 
 
    vertical-align: top; 
 
    width: 90px; 
 
} 
 

 
.hide { 
 
    display: none; 
 
} 
 

 
.item { 
 
    height: 100px; 
 
    background: #ddd; 
 
    margin: 20px; 
 
} 
 

 
.cnt { 
 
    padding-bottom: 10vh 
 
}
<div class="wrap"> 
 
    <div class="sidebar">Sidebar</div> 
 
    <main> 
 
    <header><span> </span></header> 
 
    <div class="cnt"> 
 
     <div class="item"><a href="">click me</a> or select me </div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
     <div class="item"></div> 
 
    </div> 
 
    </main> 
 
</div>

+0

thx,它的工作原理。但@Jacob Desight提供了一個更簡單的解決方案,我不能回答兩個帖子 – DTXqueque

+0

@DTXqueque沒有問題,這是你的問題;)額外的標記或虛擬僞造同樣的東西被修復來創建一個面具,一個使用陰影,另一個邊界。相同的視覺效果,**你是否檢查過,如果你可以選擇你的文本或通過鼠標達到鏈接或表單?**,我的建議是... –

+0

是啊,你是對的,我不能。但使用box-shadow我可以通過陰影選擇文本。我想我應該在這裏使用preudo-elements。 – DTXqueque

相關問題