У меня есть календарь, который я пытаюсь создать для клиента.Я хочу, чтобы боковая панель была такой же высоты, как и календарь, без установки явного размера в пикселях, поскольку это должно быть отзывчивым.Я искал около 20 других вопросов, похожих на мой, здесь, и я еще не нашел решения для этого.HTML и CSS для этого календаря ниже.
html {
line-height: 1.15;
-webkit-text-size-adjust: 100%;
font-size: 10px;
scroll-behavior: smooth;
font-family: 'Advent Pro';
}
*,
*::before,
*:after {
box-sizing: border-box;
margin: 0;
padding: 0
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section {
display: block
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible
}
pre {
font-family: monospace, monospace;
font-size: 1rem
}
a {
background-color: transparent
}
abbr[title] {
border-bottom: none;
text-decoration: underline;
text-decoration: underline dotted
}
b,
strong {
font-weight: bolder
}
code,
kbd,
samp {
font-family: monospace, monospace;
font-size: 1rem
}
small {
font-size: 80%
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline
}
sub {
bottom: -.25rem
}
sup {
top: -.25rem
}
img {
border-style: none
}
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
font-size: 1rem;
line-height: 1.15;
margin: 0
}
button,
input {
overflow: visible
}
button,
select {
text-transform: none
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0
}
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText
}
fieldset {
padding: .35rem .75rem .625rem
}
legend {
box-sizing: border-box;
color: inherit;
display: table;
max-width: 100%;
padding: 0;
white-space: normal
}
progress {
vertical-align: baseline
}
textarea {
overflow: auto
}
[type="checkbox"],
[type="radio"] {
box-sizing: border-box;
padding: 0
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto
}
[type="search"] {
-webkit-appearance: textfield;
outline-offset: -2px
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none
}
::-webkit-file-upload-button {
-webkit-appearance: button;
font: inherit
}
details {
display: block
}
summary {
display: list-item
}
template {
display: none
}
[hidden] {
display: none
}
ol,
ul {
list-style: none
}
blockquote,
q {
quotes: none
}
blockquote::before,
blockquote::after,
q::before,
q::after {
content: '';
content: none
}
table {
border-collapse: collapse;
border-spacing: 0
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 200;
src: local("Advent Pro ExtraLight"), local("AdventPro-ExtraLight"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjfWMPbJ4C-s0.woff2) format("woff2");
unicode-range: U+0370-03FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 200;
src: local("Advent Pro ExtraLight"), local("AdventPro-ExtraLight"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjfWMPb94C-s0.woff2) format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 200;
src: local("Advent Pro ExtraLight"), local("AdventPro-ExtraLight"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjfWMPbF4Cw.woff2) format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 400;
src: local("Advent Pro Regular"), local("AdventPro-Regular"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mAoQfxVT4Dvddr_yOwhTmtKI5Z.woff2) format("woff2");
unicode-range: U+0370-03FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 400;
src: local("Advent Pro Regular"), local("AdventPro-Regular"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mAoQfxVT4Dvddr_yOwhTStKI5Z.woff2) format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 400;
src: local("Advent Pro Regular"), local("AdventPro-Regular"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mAoQfxVT4Dvddr_yOwhTqtKA.woff2) format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 600;
src: local("Advent Pro SemiBold"), local("AdventPro-SemiBold"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjeWJPbJ4C-s0.woff2) format("woff2");
unicode-range: U+0370-03FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 600;
src: local("Advent Pro SemiBold"), local("AdventPro-SemiBold"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjeWJPb94C-s0.woff2) format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 600;
src: local("Advent Pro SemiBold"), local("AdventPro-SemiBold"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjeWJPbF4Cw.woff2) format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 700;
src: local("Advent Pro Bold"), local("AdventPro-Bold"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjYGIPbJ4C-s0.woff2) format("woff2");
unicode-range: U+0370-03FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 700;
src: local("Advent Pro Bold"), local("AdventPro-Bold"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjYGIPb94C-s0.woff2) format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
font-family: 'Advent Pro';
font-style: normal;
font-weight: 700;
src: local("Advent Pro Bold"), local("AdventPro-Bold"), url(https://fonts.gstatic.com/s/adventpro/v7/V8mDoQfxVT4Dvddr_yOwjYGIPbF4Cw.woff2) format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}
.container {
width: 100%;
margin: 0 auto;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
z-index: 1
}
h1,
h2,
h3,
h4,
h5,
h6 {
font: normal 700 2rem/3rem 'Advent Pro';
color: #212121;
text-align: center;
text-transform: uppercase
}
h3,
h4 {
font-weight: 600
}
h4 {
font-size: 2.875rem
}
@media only screen and (min-width: 120em) {
h4 {
font-size: 4.25rem
}
}
@media only screen and (min-width: 240em) {
h4 {
font-size: 7.875rem
}
}
a {
position: relative;
text-decoration: none;
color: #212121;
opacity: 1;
line-height: inherit;
transition: color 100ms cubic-bezier(0.2, 0.3, 0.25, 0.9) 0s
}
a:hover {
color: #FFB819;
transition: color 100ms cubic-bezier(0.2, 0.3, 0.25, 0.9) 0s
}
@media only screen and (min-width: 120em) {
p {
margin: 1rem 0
}
}
@media only screen and (min-width: 240em) {
p {
margin: 2.5rem 0
}
}
::selection,
*::selection {
background: #FFB819;
color: #000000;
text-shadow: none
}
.calendar-sidebar {
width: 100%;
display: block;
border-radius: .5rem .5rem 0 0;
background-color: #FFB819;
color: white;
float: left;
margin: 0 2rem;
align-content: stretch
}
@media only screen and (min-width: 48em) {
.calendar-sidebar {
width: calc(50% - 2rem);
height: inherit;
border-radius: .5rem 0 0 .5rem;
margin: 0 0 0 2rem
}
}
.calendar-sidebar .currentdate {
width: 100%;
padding: 2rem 2rem 0;
display: flex;
align-items: center
}
.calendar-sidebar .currentdate .left,
.calendar-sidebar .currentdate .right {
width: 50%;
display: block;
float: left
}
.calendar-sidebar .currentdate .left {
text-align: right;
padding-right: .5rem
}
.calendar-sidebar .currentdate .left .dayofweek,
.calendar-sidebar .currentdate .left .monthofdate {
width: 100%;
font-size: 3rem;
text-transform: uppercase;
text-align: right;
display: block
}
@media only screen and (min-width: 48em) {
.calendar-sidebar .currentdate .left .dayofweek,
.calendar-sidebar .currentdate .left .monthofdate {
font-size: 4rem
}
}
.calendar-sidebar .currentdate .right {
text-align: left;
padding-left: .5rem
}
.calendar-sidebar .currentdate .right .numdate {
font-size: 15rem;
font-weight: 700
}
@media only screen and (min-width: 48em) {
.calendar-sidebar .currentdate .right .numdate {
font-size: 11rem
}
}
.calendar-sidebar .currentevents {
padding: 4rem 2rem 2rem;
font-size: 3rem;
text-transform: uppercase
}
.calendar-sidebar .currentevents ul {
padding-left: 1rem;
text-transform: none;
font-size: 2.5rem
}
.calendar-base {
width: 100%;
display: block;
color: black;
float: left;
margin: 0 2rem;
padding-top: 2rem
}
@media only screen and (min-width: 48em) {
.calendar-base {
width: calc(50% - 2rem);
height: inherit;
margin: 0 2rem 0 0
}
}
.calendar-base .yearNav {
display: inline-block;
float: right;
width: 100%;
padding: 0 2rem
}
.calendar-base .yearNav a,
.calendar-base .yearNav h4 {
display: inline-block;
float: right
}
.calendar-base .monthNav {
display: inline-grid;
width: 100%;
padding: 2rem 2rem 0;
grid-template-columns: repeat(12, 1fr)
}
.calendar-base .monthNav .month {
text-align: center;
font-weight: 600;
color: #aaa
}
.calendar-base .monthNav .month.active {
color: #FFB819
}
.calendar-base .hrbreak {
display: inline-block;
width: 100%;
padding: 0 2rem
}
.calendar-base .hrbreak .break {
border-bottom: 1px solid #424242
}
.calendar-base .weekdays {
display: inline-grid;
width: 100%;
padding: 2rem 2rem;
grid-template-columns: repeat(7, 1fr)
}
.calendar-base .weekdays .weekday {
text-align: center;
font-weight: 600;
color: #aaa;
text-transform: uppercase
}
.calendar-base .calendar-grid {
display: grid;
grid-template-columns: repeat(7, 1fr);
grid-auto-rows: 1fr;
padding: 0 2rem 0
}
.calendar-base .calendar-grid::before {
content: '';
width: 0;
padding-bottom: 100%;
grid-row: 1 / 1;
grid-column: 1 / 1
}
.calendar-base .calendar-grid>* {
border: 1px solid white
}
.calendar-base .calendar-grid>*:first-child {
grid-row: 1 / 1;
grid-column: 1 / 1
}
.calendar-base .calendar-grid .day {
display: flex;
position: relative;
justify-content: center;
align-items: center;
font-weight: 700
}
.calendar-base .calendar-grid .day.today {
border-radius: 50%;
background: #FFB819;
color: white;
margin: 20%
}
.calendar-base .calendar-grid .day.last-month,
.calendar-base .calendar-grid .day.next-month {
color: #aaa
}
.calendar-base .calendar-grid .day .event-indicator {
display: block;
position: absolute;
width: 5px;
height: 5px;
border-radius: 50%;
background-color: #2980B9;
top: 304px;
left: 695px
}
.calendar-base .months {
color: #aaa;
word-spacing: 10px
}
.posts {
text-decoration: underline dotted
}
.posts:hover {
color: #27e879 !important
}
.create-event {
font-size: 18px;
position: relative;
margin-top: 30px;
margin-left: 25px
}
.event-line {
width: 90%
}
.add-event {
width: 20px;
height: 20px;
padding: 0px;
border-radius: 50%;
border: solid white 2px;
position: relative;
bottom: 42px;
left: 260px
}
.add {
font-size: 25px;
position: relative;
left: 4px;
bottom: 10px
}
.add:hover,
.create-event:hover,
.add-event:hover {
color: #27e879 !important;
border-color: #27e879 !important
}
<head>
<link rel="preload" href="https://fonts.gstatic.com/s/adventpro/v7/V8mAoQfxVT4Dvddr_yOwhTqtKA.woff2" as="font" crossorigin>
<link rel="preload" href="https://fonts.gstatic.com/s/adventpro/v7/V8mAoQfxVT4Dvddr_yOwhTStKI5Z.woff2" as="font" crossorigin>
<link rel="preload" href="https://fonts.gstatic.com/s/materialicons/v41/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2" as="font" crossorigin>
</head>
<body>
<div class="container cal">
<div class="calendar-sidebar">
<div class="currentdate">
<div class="left">
<div class="dayofweek">wednesday
<?php ?>
</div>
<div class="monthofdate">february
<?php ?>
</div>
</div>
<div class="right">
<div class="numdate">27
<?php ?>
</div>
</div>
</div>
<div class="currentevents">Current Events
<ul>
<li>Toddler Time
<ul>
<li>10:00AM</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="calendar-base">
<div class="yearNav">
<a class="yearlink" onclick="openYear(event, 'Next')"> ></a>
<h4>
2019 </h4>
<a class="tablinks" onclick="openYear(event, 'Previous')">< </a>
</div>
<div class="monthNav">
<a class="month">Jan</a>
<a class="month active">Feb</a>
<a class="month">Mar</a>
<a class="month">Apr</a>
<a class="month">May</a>
<a class="month">Jun</a>
<a class="month">Jul</a>
<a class="month">Aug</a>
<a class="month">Sep</a>
<a class="month">Oct</a>
<a class="month">Nov</a>
<a class="month">Dec</a>
</div>
<div class="hrbreak">
<div class="break"></div>
</div>
<div class="weekdays">
<div class="weekday">sun</div>
<div class="weekday">mon</div>
<div class="weekday">tue</div>
<div class="weekday">wed</div>
<div class="weekday">thu</div>
<div class="weekday">fri</div>
<div class="weekday">sat</div>
</div>
<div class="calendar-grid">
<div id="jan27" class="day last-month">27</div>
<div id="jan28" class="day last-month">28</div>
<div id="jan29" class="day last-month">29</div>
<div id="jan30" class="day last-month">30</div>
<div id="jan31" class="day last-month">31</div>
<div id="feb01" class="day">1</div>
<div id="feb02" class="day">2</div>
<div id="feb03" class="day">3</div>
<div id="feb04" class="day">4</div>
<div id="feb05" class="day">5</div>
<div id="feb06" class="day">6</div>
<div id="feb07" class="day">7</div>
<div id="feb08" class="day">8</div>
<div id="feb09" class="day">9</div>
<div id="feb10" class="day">10</div>
<div id="feb11" class="day">11</div>
<div id="feb12" class="day">12</div>
<div id="feb13" class="day">13</div>
<div id="feb14" class="day">14</div>
<div id="feb15" class="day">15</div>
<div id="feb16" class="day">16</div>
<div id="feb17" class="day">17</div>
<div id="feb18" class="day">18</div>
<div id="feb19" class="day">19</div>
<div id="feb20" class="day">20</div>
<div id="feb21" class="day">21</div>
<div id="feb22" class="day">22</div>
<div id="feb23" class="day">23</div>
<div id="feb24" class="day">24</div>
<div id="feb25" class="day">25
<div class="event-indicator"></div>
</div>
<div id="feb26" class="day">26
<div class="event-indicator"></div>
</div>
<div id="feb27" class="day today">27
<div class="event-indicator"></div>
<div class="event-indicator"></div>
<div class="event-indicator"></div>
</div>
<div id="feb28" class="day">28</div>
<div id="mar01" class="day next-month">1</div>
<div id="mar02" class="day next-month">2
<div class="event-indicator"></div>
</div>
<div id="mar03" class="day next-month">3</div>
<div id="mar04" class="day next-month">4</div>
<div id="mar05" class="day next-month">5</div>
<div id="mar06" class="day next-month">6</div>
<div id="mar07" class="day next-month">7</div>
<div id="mar08" class="day next-month">8</div>
<div id="mar09" class="day next-month">9</div>
</div>
</div>
</div>
</body>
Я хотел бы найти решение CSS для этого и не использовать JavaScript, если мне не нужно.
Вторая проблема, которую яУ меня получилось, что индикатор событий отображается в верхней части div
, внутри которого он находится, а не в нижней части календаря.
Что я делаю не так?