1
A
回答
2
您可以使用圓角半徑達到這個佈局:
如果你想要一個橢圓形,你必須特大型剪裁元素並把它裏面抵消圖像:
document.getElementById('button1').addEventListener('click', function(){
document.getElementById('profile').classList.toggle('view');
});
.profile{
background: #1111cc;
width:300px;
height:100px;
position:relative;
overflow:hidden;
margin: 20px;
}
.clip{
position:absolute;
background: red;
width: 100px;
height:130px;
top: -15px;
border-top-right-radius: 50px 65px;
border-bottom-right-radius: 50px 65px;
overflow:hidden;
}
.img{
position: absolute;
top: 15px;
background: rgba(100,100,100,0.8);
width:100px;
height:100px;
}
.name{
position: absolute;
bottom: 15px;
margin: 0;
padding: 0 10px 0 0;
background: rgba(255, 255, 255, 0.8);
box-sizing: border-box;
width: 100px;
}
.profile.view .clip{
overflow: initial;
}
.profile.view{
overflow: initial;
}
<div id="profile" class="profile">
<div class="clip">
<img class="img" src="https://i.stack.imgur.com/oiszU.png">
<p class="name">My name is too long for this world..</p>
</div>
</div>
<button id="button1">view all shapes</button>
相關問題
- 1. 在Android瀏覽器上的SVG渲染
- 2. Android瀏覽器中的SVG
- 3. 基於svg的Fabric.js多重剪輯
- 4. 火狐SVG:剪輯
- 5. SVG在不同瀏覽器
- 6. IE瀏覽器,SVG和XHTML
- 7. 跨瀏覽器SVG preserveAspectRatio
- 8. paper.js,SVG和Opera瀏覽器
- 9. 跨瀏覽器SVG> HTML
- 10. .SVG瀏覽器支持
- 11. 從瀏覽器打印SVG
- 12. D3(SVG)瀏覽器支持
- 13. SVG瀏覽器問題
- 14. Flash滾動瀏覽影片剪輯
- 15. SVG動畫無法在多個瀏覽器上工作
- 16. 跨瀏覽器SVG Textpath(Safari瀏覽器和Firefox)
- 17. svg clipPath不會剪輯
- 18. svg編輯記事本和流瀏覽器
- 19. 用於HTML5瀏覽器的SVG或Canvas?
- 20. SVG/VML瀏覽器的兼容性表
- 21. Chrome瀏覽器的模糊SVG圖像
- 22. 在iOS瀏覽器中的SVG
- 23. 在瀏覽器中播放動態聲音剪輯
- 24. 跨瀏覽器與多瀏覽器
- 25. 如何在沒有svg的情況下爲所有瀏覽器製作兼容的剪輯路徑css屬性?
- 26. 瀏覽器上的
- 27. 移動Safari瀏覽器的SVG太多了嗎?
- 28. IE瀏覽器'use'鏈接中的SVG上的ClipPath
- 29. 瀏覽器縮放和.SVG圖片
- 30. 互聯網瀏覽器jquery + SVG
您是否嘗試過使用畫布? https://stackoverflow.com/questions/4276048/html5-canvas-fill-circle-with-image – Bellian
問題是,這是一個配置文件圖像,所以它由每個用戶更改。我無法在CSS中使用修復圖像。 這樣很棒的裁剪div元素。 – kdskii
畫布可以執行圖像處理(請參閱鏈接)或更精確:https://stackoverflow.com/a/6889378/3588584。客戶端然後將裁剪圖像並顯示它。不需要固定的圖像,並得到廣泛的支持。 – Bellian