I'm currently utilizing a Bootstrap 4 masonry card layout for a particular project, and within this project, there is a <select>
element that has been styled with custom CSS properties. One of the customized styles includes a caret created using CSS's :after
pseudo-element. However, I have noticed that different browsers are rendering this element differently, leading to inconsistent results. I decided to share this issue here in the hopes that someone might have a solution. I am uncertain whether this discrepancy is due to a problem with Bootstrap or a CSS specification issue, so any insights would be greatly appreciated.
- Chrome Canary: the appearance is consistent
- Chrome: the first column displays correctly, but subsequent columns exhibit issues, except in the mobile view where it appears as intended. The problem seems to occur only with multiple columns.
- Firefox: everything appears as expected
- Safari: the caret and text are visible in the first column, but they are missing in subsequent columns.
For reference, here is a link to the Codepen: http://codepen.io/derekshull/pen/GZQaRY
.select-fancy {
display: inline-block;
border: 1px solid #bac2c6;
position: relative;
padding: 5px 10px;
border-radius: 20px;
width: 100%;
overflow: hidden;
color: #656565;
box-shadow: inset 0 -2px 5px rgba(255, 255, 255, 0.4);
background: #eee;
}
.select-fancy,
.select-fancy > * {
cursor: pointer;
}
.select-fancy select {
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
background: transparent;
border: 0;
outline: 0;
text-shadow: 1px 1px rgba(255, 255, 255, 0.7);
font-size: 14px;
width: calc(100% - 23px);
-webkit-user-select: none;
-moz-user-select: -moz-none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-appearance: none;
-moz-appearance: radio-container;
appearance: none;
float: left;
padding-left: 5px;
}
.select-fancy:after {
content: '';
display: block;
white-space: nowrap;
position: absolute;
width: 0;
height: 0;
right: 11px;
top: 50%;
margin-top: -4px;
border-width: 8px 6px;
border-style: solid;
pointer-events: none;
border-color: #656565 transparent transparent transparent;
}
.select-fancy img {
width: 17px;
height: 17px;
float: left;
margin-top: 1px;
}
@media (max-width: 595px) {
.card-columns {
-webkit-column-count: 1;
-moz-column-count: 1;
column-count: 1;
}
}
@media (min-width: 596px) and (max-width: 991px) {
.card-columns {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
}
<section class="card-columns">
<div class="card card-block">
<h2 class="card-title"><a href="#">Card Title</a></h2>
<p class="card-text"></p>
<fieldset class="clearfix">
<div class="select-fancy">
<select class="urlSelect" data-projectid="12">
<option value="Homepage">Homepage</option>
<option value="Board Members">Board Members</option>
<option value="Events">Events</option>
</select>
</div>
</fieldset>
</div>
<div class="card card-block">
<h2 class="card-title"><a href="#">Card Title</a></h2>
<p class="card-text"></p>
<fieldset class="clearfix">
<div class="select-fancy">
<select class="urlSelect" data-projectid="12">
<option value="Homepage">Homepage</option>
<option value="Board Members">Board Members</option>
<option value="Events">Events</option>
</select>
</div>
</fieldset>
</div>
<div class="card card-block">
<h2 class="card-title"><a href="#">Card Title</a></h2>
<p class="card-text"></p>
<fieldset class="clearfix">
<div class="select-fancy">
<select class="urlSelect" data-projectid="12">
<option value="Homepage">Homepage</option>
<option value="Board Members">Board Members</option>
<option value="Events">Events</option>
</select>
</div>
</fieldset>
</div>
</section>