gpt4 book ai didi

html - 无法让 % 宽度在 div 表上工作

转载 作者:太空狗 更新时间:2023-10-29 16:06:29 25 4
gpt4 key购买 nike

所以我正在为一个网站制作每日计划 View ,但我在格式化它时遇到了问题。这是我下面的代码:

CSS

.responsive-calendar .controls {
color: #666;
font-weight: normal;
font-size: 18px;
font-family: "Open Sans",Arial,Verdana,sans-serif;
text-align: left;
}

.responsive-calendar .controls a {
cursor: pointer;
}

.responsive-calendar .controls h4 {
display: inline;
}

.responsive-calendar .day-headers, .responsive-calendar .days, .responsive-calendar .timeslots {
font-size: 0;
}

.responsive-calendar .header {
background-color: #f3f2f2 !important;
box-shadow: 0px 1px 0px 0px rgb(255, 255, 255) inset;
color: rgb(102, 102, 102);
font-size: 13px;
line-height: 18px;
padding: 10px 0px;
font-weight: bold;
cursor:default !important;
}

/* Daily Planner CSS */
.responsive-calendar .timeslot {
height:auto;
display:flex;
display:-webkit-flex;
flex-flow: row column;
-webkit-flex-flow: row column;
}

.responsive-calendar .hour {
display: inline-block;
position: relative;
font-size: 10px;
border:1px solid rgb(221, 221, 221);
width: 10%;
text-align: center;
flex: 1 1 100%;
-webkit-flex:1 1 100%;
}

.responsive-calendar .appts {
height:auto;
display:flex;
display:-webkit-flex;
width: 900%;
flex-flow: row column;
-webkit-flex-flow: row column;
}

.responsive-calendar .appt {
background-color:#CCC;
display: inline-block;
position: relative;
font-size: 10px;
border:1px solid rgb(221, 221, 221);
width: 90%;
text-align: center;
flex: 1 1 100%;
-webkit-flex:1 1 100%;
}

.responsive-calendar .appt a {
color: #000000;
display: block;
cursor: pointer;
padding: 5% 0 5% 0;
}

.responsive-calendar .timesection {
display: inline-block;
position: relative;
font-size: 10px;
border:1px solid rgb(221, 221, 221);
text-align: center;
flex: 1 1 100%;
-webkit-flex:1 1 100%;
}

.responsive-calendar .timesection:hover {
background-color: rgb(227, 235, 253);
cursor: pointer;
text-decoration: none;
}

.responsive-calendar .timesection a {
color: #000000;
display: block;
cursor: pointer;
padding: 3% 0 3% 0;
}

.responsive-calendar .timesection a:hover {
/* background-color: #eee; */
text-decoration: none;
}

.responsive-calendar .timesection.header {
border-bottom: 1px gray solid;
}

.responsive-calendar .timesection.active {
background-color: rgb(209, 206, 224);
}

.responsive-calendar .timesection.active:hover {
background-color: rgb(227, 235, 253);
}

.responsive-calendar .timesection.not-current {
background-color: rgb(205, 205, 205);
cursor:default;
}

HTML

<div class="responsive-calendar">
<div class="controls">
<img src="images/left_16.png" />
<?php echo date("M d, Y", mktime(0,0,0,$cMonth,$cDay,$cYear)); ?>
<img src="images/right_16.png" />
<a style="padding-left:15px;">Today</a>
<a style="padding-left:15px;">Monthly View</a>
</div>
<div class="day-headers">
<div class="hour header"><strong>Times</strong></div>
<div class="appt header"><strong>Appointments</strong></div>
</div>
<div class="timeslots">
<div class="timeslot">
<div class="timesection hour">10:00am</div>
<div class="timesection appt">Test 1</div>
</div>
<div class="timeslot">
<div class="timesection hour">11:00am</div>
<div class="timesection appt">Test 2</div>
<div class="timesection appt">Test 3</div>
</div>
<div class="timeslot">
<div class="timesection hour">12:00pm</div>
<div class="appts">
<div class="timesection appt">Hack Result 1</div>
</div>
</div>
<div class="timeslot">
<div class="timesection hour">12:00pm</div>
<div class="appts">
<div class="timesection appt">Hack Result 2</div>
<div class="timesection appt">Hack Result 3</div>
</div>
</div>
</div>
</div>

这是一个JSFiddle demo .

所以在demo中,我想要的是破解后的结果(div表的最后2行)。

我正在使用 bootstrap 3.3.4 和附加的 CSS 来设置页面样式。我不确定为什么我不能让标题 div 按百分比(10%、90%)正确排列,但下面的 div 不想在下面匹配。

在黑客攻击的结果中,我刚刚添加了另一个类 appts,并将其膨胀到 900%,它接近我想要的。但我想正确地完成这项工作,并了解为什么它没有像我希望的那样工作。

我想要的是始终是可用宽度的 10%,然后 appts 占据可用宽度的 90%。如果有多个 .appt,则将 90% 的宽度平分。

最佳答案

这个怎么样:

.responsive-calendar .controls {
color: #666;
font-weight: normal;
font-size: 18px;
font-family: "Open Sans", Arial, Verdana, sans-serif;
text-align: left;
}
.responsive-calendar .controls a {
cursor: pointer;
}
.responsive-calendar .day-headers,
.responsive-calendar .days,
.responsive-calendar .timeslots {
font-size: 0;
}
.responsive-calendar .header {
background-color: #f3f2f2 !important;
box-shadow: 0px 1px 0px 0px rgb(255, 255, 255) inset;
color: rgb(102, 102, 102);
font-size: 13px;
line-height: 18px;
padding: 10px 0px;
font-weight: bold;
cursor: default !important;
}
.responsive-calendar .hour {
font-size: 10px;
border: 1px solid rgb(221, 221, 221);
width: 10%;
text-align: center;
max-width: 10%;
float: left;
}
.responsive-calendar .appts {
height: auto;
display: flex;
}
.responsive-calendar .appt {
background-color: #CCC;
font-size: 10px;
border: 1px solid rgb(221, 221, 221);
text-align: center;
}
.responsive-calendar .appt a {
color: #000000;
display: block;
cursor: pointer;
padding: 5% 0 5% 0;
}
.responsive-calendar .timesection {
display: inline-block;
position: relative;
font-size: 10px;
border: 1px solid rgb(221, 221, 221);
text-align: center;
flex: 1 1 100%;
-webkit-flex: 1 1 100%;
}
.responsive-calendar .timesection:hover {
background-color: rgb(227, 235, 253);
cursor: pointer;
text-decoration: none;
}
.responsive-calendar .timesection a {
color: #000000;
display: block;
cursor: pointer;
padding: 3% 0 3% 0;
}
.responsive-calendar .timesection a:hover {
text-decoration: none;
}
.responsive-calendar .timesection.header {
border-bottom: 1px gray solid;
}
.responsive-calendar .timesection.active {
background-color: rgb(209, 206, 224);
}
.responsive-calendar .timesection.active:hover {
background-color: rgb(227, 235, 253);
}
.responsive-calendar .timesection.not-current {
background-color: rgb(205, 205, 205);
cursor: default;
}
.appt {
max-width: 100%;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />

<div class="responsive-calendar">
<div class="controls">
<img src="images/left_16.png" />
<?php echo date( "M d, Y", mktime(0,0,0,$cMonth,$cDay,$cYear)); ?>
<img src="images/right_16.png" /> <a style="padding-left:15px;">Today</a>
<a style="padding-left:15px;">Monthly View</a>

</div>
<div class="day-headers">
<div class="hour header"><strong>Times</strong>
</div>
<div class="appt header"><strong>Appointments</strong>
</div>
</div>
<div class="timeslots">
<div class="timeslot">
<div class="timesection hour">10:00am</div>
<div class="appts">

<div class="timesection appt">Test 1</div>
</div>
</div>
<div class="timeslot">
<div class="timesection hour">11:00am</div>
<div class="appts">
<div class="timesection appt ">Test 2</div>
<div class="timesection appt ">Test 3</div>
</div>
</div>
<div class="timeslot">
<div class="timesection hour">12:00pm</div>
<div class="appts">
<div class="timesection appt">Hack Result 1</div>
</div>
</div>
<div class="timeslot">
<div class="timesection hour">12:00pm</div>
<div class="appts">
<div class="timesection appt">Hack Result 2</div>
<div class="timesection appt">Hack Result 3</div>
</div>
</div>
</div>
</div>

我做了什么:

HTML:

  • div.appts 包装了具有 .timesection .appt 的元素。

CSS:

  • 完全删除了 .responsive-calendar .timeslot CSS。

  • 删除了 display:inline-block;position:relative; 并添加了 float:left;。响应日历.hour

  • 移除了display:-webkit-flex;, width: 900%;, flex-flow: row column;, -webkit-flex-flow: row column; 来自 .responsive-calendar .appts

  • .responsive-calendar 中移除了 flexwidthpositiondisplay .appt

  • 最后添加.appt一个max-width: 100%;

同时找到一个 example pen .

关于html - 无法让 % 宽度在 div 表上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29898064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com