简体   繁体   English

在非矩形对象周围浮动文本

[英]Floating text around a non-rectangular object

I need to float some text around a spangle on my page as you can see on the attached screenshot. 我需要在页面上的亮片周围浮动一些文本,如所附的屏幕截图所示。 I'd like to not to use JavaScript. 我不想使用JavaScript。 Is that possible to do in pure CSS? 在纯CSS中可以做到吗?

布局示例

Use CSS shapes if you're not too worried about compatability with older browsers. 如果您不太担心与旧版浏览器的兼容性,请使用CSS形状。

.element{
  shape-outside: url(image.png);
  shape-image-threshold: 0.5;
  float: left;
}

http://www.html5rocks.com/en/tutorials/shapes/getting-started/ http://www.html5rocks.com/en/tutorials/shapes/getting-started/

Might the padding attribute be what you mean? padding属性可能是您的意思吗?

 .container { background: url('someimage.png') no-repeat left bottom; border: 1px solid #111; color: #666; font: 9pt/14pt 'consolas'; padding: 40px 12px 12px 40px; } 
 <div class="container"> Lorem ipsum dolor sit amet, consectetur adipiscing 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. </div> 

Oooh... I didn't know that you meant the text bending over the image! 哦,我不知道您是说文字在图像上弯曲! sorry, See evilunix' answer, as I don't want to copy someone else's solution. 抱歉,请参见evilunix的答案,因为我不想复制其他人的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM