html - 使用 bootstrap 在悬停时边框到 div 的边缘

标签 html css twitter-bootstrap-3

有没有办法在悬停时只为 div 的边缘创建边框。这是我使用 bootstrap 创建的网格的基本布局。这是我的代码笔 http://codepen.io/anon/pen/zvxEYw

  <div class="product-grid col-md-4">
    <a class="preview" href="#">PREVIEW</a>
  </div>

.product-grid{
  margin:30px 0 0 30px;
  border:1px solid #ccc;
  height:300px;
  display:block;
}
.product-grid:hover{
  border:1px solid #000;
}
/* Preview */
.preview {
  opacity: 0;
  position: absolute;
  left: 40px;
  right: 40px;
  top: 0;
  height: 30px;
  line-height: 32px;
  background-color: #fe3;
  text-align: center;
  text-decoration: none;
  color: #000;
  transition: .2s;
}

.product-grid:hover .preview {
  opacity: 1;
  top: 80px;
}

为了清楚理解,我在下面附上了示例图片

enter image description here

最佳答案

要达到那种效果,最好使用 CSS3,我已经使用 <svg> 做到了。作为:

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
            <line class="top" x1="0" y1="0" x2="900" y2="0" />
            <line class="left" x1="0" y1="460" x2="0" y2="-920" />
            <line class="bottom" x1="300" y1="460" x2="-600" y2="460" />
            <line class="right" x1="300" y1="0" x2="300" y2="1380" />
</svg>

这里查看我的JSFiddle ,希望你正在寻找这样的东西。 它会为您解决问题。

进一步的自定义没什么大不了的,只需查看其 CSS 即可根据您的要求进行更改。

来源:tympanus

关于html - 使用 bootstrap 在悬停时边框到 div 的边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32391102/

相关文章:

css - 如何使用现有 ID 添加和设置 CSS 类的样式

html - 无法在悬停时更改 css 中的背景图像

html - 不透明度属性在 css 中没有给出预期的结果

css - 内容溢出时展开div

html - 如何将 CSS 样式应用于 HTML 表格中的特定行?

java - 从 java 文档中删除 html 标签的最快方法是什么?

javascript - 我希望下面的按钮代码打开一个新选项卡,其中包含从 js 变量中获取的 URL

html - 在 iOS safari 中输入焦点后模态(固定元素)不可滚动

css - 如何在更大的屏幕尺寸下自动调整 _layout.cshtml?

javascript - 如何在 javascript 中向 borderStyle Canvas 添加渐变