我有一个自定义的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;
}
添加边框。
这会导致整个日历变大。
我尝试了边框间距和折叠属性而没有运气。
当边框添加到选定日期时,是否有办法让日历不会增长?
由于
答案 0 :(得分: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;
}
答案 1 :(得分:0)
如上所述,您可以使用不会增加尺寸的大纲,也可以使用大小调整,它会将边框带入内容空间。
这里的例子 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>