0

我有一个自定义的 asp.net 日历。选择日期后,它将运行以下样式:

.calendar-cell
{
    -webkit-border-radius: 7px;
    border-radius: 7px;
    background: rgb(239,239,239); /* Old browsers */
    background: -moz-linear-gradient(-45deg, rgba(239,239,239,1) 0%, rgba(235,235,235,1) 50%, rgba(229,229,229,1) 51%, rgba(254,254,254,1) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,rgba(239,239,239,1)), color-stop(50%,rgba(235,235,235,1)), color-stop(51%,rgba(229,229,229,1)), color-stop(100%,rgba(254,254,254,1))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(-45deg, rgba(239,239,239,1) 0%,rgba(235,235,235,1) 50%,rgba(229,229,229,1) 51%,rgba(254,254,254,1) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(-45deg, rgba(239,239,239,1) 0%,rgba(235,235,235,1) 50%,rgba(229,229,229,1) 51%,rgba(254,254,254,1) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(-45deg, rgba(239,239,239,1) 0%,rgba(235,235,235,1) 50%,rgba(229,229,229,1) 51%,rgba(254,254,254,1) 100%); /* IE10+ */ /* W3C */
    border-style: solid;
    border-width: thin;
    border-color: inherit;
    background: linear-gradient(135deg, rgba(239,239,239,1) 0%,rgba(235,235,235,1) 50%,rgba(229,229,229,1) 51%,rgba(254,254,254,1) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#efefef', endColorstr='#fefefe',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
    border-collapse:collapse !important;
    -webkit-box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.08);
    box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.08);
    color: #019fde !important;
}

这增加了一个边框。

这会导致整个日历变大。

我试过没有运气的边框间距和折叠属性。

当边框被添加到选定的日期时,有没有办法让日历不增长?

谢谢

4

2 回答 2

1

不幸的是,这就是边界的工作方式。如果你的边框是 1px 宽,那么它会占用 1px 的空间。

您可以改用该outline属性。它实际上与边框相同,但没有随之而来的不受欢迎的额外宽度/高度。您可以在下面的演示中看到,包含轮廓元素的元素集合比包含边框元素的元素集合窄 20px。

http://codepen.io/cimmanon/pen/wyktr

<div class="container">
  <div class="solid"></div>
  <div class="bordered"></div>
  <div class="solid"></div>
</div>

<div class="container">
  <div class="solid"></div>
  <div class="outlined"></div>
  <div class="solid"></div>
</div>

div.container {
  display: table;
  margin: 1em;
}

div.container div {
  display: table-cell;
  width: 100px;
  height: 100px;
}

.bordered {
  border: 10px solid orange;
}

.outlined {
  outline: 10px solid red;
}

.solid {
  background: #CCC;
}

http://caniuse.com/#search=outline

于 2013-02-25T20:38:14.190 回答
0

如上所述,您可以使用不会增加大小的轮廓,也可以使用将边框带入内容空间的box-sizing 。

例如这里 http://jsfiddle.net/Y5VmT/

div {
    width: 200px;
    height: 200px;
    border: 2px solid black;
    background: grey;
}

.sizing {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -o-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
}


<div>
    pppppppppppppp pppppppppppppppppp pppppppppppppppppppppp
    pppppppppppppp pppppppppppppppppp pppppppppppppppppppppp
    pppppppppppppp pppppppppppppppppp pppppppppppppppppppppp
</div>


<div class="sizing">
    pppppppppppppp pppppppppppppppppp pppppppppppppppppppppp
    pppppppppppppp pppppppppppppppppp pppppppppppppppppppppp
    pppppppppppppp pppppppppppppppppp pppppppppppppppppppppp
</div>
于 2013-02-25T20:59:18.253 回答