A snippet of HTML code is given below:
<span class="day-number">{{day-number}}</span>
<div class="event-box">
<div class="event-container">
</div>
<div class="more-events">more ...</div>
</div>
The .event-container
contains several .event
elements as shown below:
<div class="event">{{event-name}}</div>
If the height of the .event-container
exceeds 76px
, the .more
element should be displayed, otherwise hidden.
The CSS styles for the elements are as follows:
.event {
text-align: left;
font-size: .85em;
line-height: 1.3;
border-radius: 3px;
border: 1px solid #3a87ad;
background-color: #3a87ad;
font-weight: normal;
color: whitesmoke;
padding: 0 1px;
overflow: hidden;
margin-bottom: 2px;
cursor: pointer;
}
.event-box {
max-height: 76px;
overflow: hidden;
position:relative;
}
.event-box .more-events {
height: 10px;
position: absolute;
right: 0;
bottom: 10px;
display: none;
z-index: 5;
}
No specific styling is provided for .event-container
.
The desired functionality can be achieved using JavaScript (jQuery) by iterating through each .event-box
and checking the height of its .event-container
. Based on this, the display property of .more-events
element is toggled.
Is there a purely CSS solution to achieve this without relying on JavaScript? Perhaps using pseudo-elements or media queries?
JSFIDDLE: http://jsfiddle.net/pitaj/LjLxuhx2/