css - 跨度边框不环绕图像

标签 css

我正在尝试使用跨度包裹图像,但是当在跨度中应用边框时,边框会被剪裁。为什么会这样?

http://jsfiddle.net/c743yeLt/1/

<span id="imagem">
    <img src="http://www.greentechmedia.com/content/images/articles/google-utility.jpg"/>
</span>

span{
    border: 5px solid black;
    cursor:pointer;
}

最佳答案

span 元素是一个内联元素。因此,要看到它更好地与子元素交互,请为 span 提供以下属性之一:

display:inline-block (probably this)
display:block

关于css - 跨度边框不环绕图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26446672/

相关文章:

javascript - jQuery 便利方法如何在我的 DOM 元素中结束?

javascript - 将剪切的 contenteditable div 的 View 移动到光标位置

php - 文本显示在图像悬停上

html - 为什么 hr 和 img 标签周围有空白?

javascript - 如何访问使用外部样式表的 javascript 对象的样式属性?

html - 将列设置为页面的全高,不超过页面大小

javascript - 为什么 jquery 数据表在搜索后没有填充新更新的数据?

html - 在响应式设计中使用 float 定位元素时出现问题

使用 React Router 路由到另一个组件时 CSS 没有改变

html - Bootstrap竖写