Reputation: 23
I'm not a CSS specialist. I have a DRUPAL site, using a theme based on bootstrap. I use the bootstrap alert boxes in order to display important messages on the homepage. It works well, except that I get extra space when adding some content in a :before selector. I created a fiddle
Is there a simple way to solve this extra space? I solved the issue by setting line-height to 0 to the ancestor of the alert, but then when reducing the page, text doesn't go to new line and gets imbricated with itself. Thanks for help.
Here is the code:
#top-content .block .views-row::before {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
color: #f37021;
content: "\e101";
display: inline-block;
font-family: 'Glyphicons Halflings';
font-size: 2em;
font-style: normal;
font-weight: 400;
left: 0.35em;
/*line-height: 1;*/
position: relative;
top: 0.3em;
}
/*#top-content .block .views-row {
padding-bottom:1.2em;
}*/
#top-content .block .views-row .views-field {
margin-left: 3em;
}
#top-content .block a {
color: #f37021;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<div id="top-content">
<div class="container clearfix">
<div class="clearfix" id="top-content-inside">
<div class="region region-highlighted">
<div class="block block-views contextual-links-region clearfix" id="block-views-alerts-block-1">
<div class="contextual-links-wrapper contextual-links-processed"><a href="#" class="contextual-links-trigger">Configure</a>
<ul class="contextual-links">
<li class="views-ui-edit first"><a href="/en/admin/structure/views/view/alerts/edit/block_1?destination=node/385">Edit view</a>
</li>
<li class="block-configure last"><a href="/en/admin/structure/block/manage/views/alerts-block_1/configure?destination=node/385">Configure</a>
</li>
</ul>
</div>
<div class="content">
<div class="view view-alerts view-id-alerts view-display-id-block_1 view-dom-id-281661d0f4b7c5128ce6ef7abc38dfb1">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first alert alert-info fade in">
<div class="views-field views-field-nothing"> <span class="field-content"><a aria-label="close" data-dismiss="alert" class="close" href="#">×</a></span>
</div>
<div class="views-field views-field-title"> <span class="field-content"><a href="/nl/content/wiv-isp-closed-between-1st-and-5th-november">WIV-ISP closed between 1st and 5th of November</a></span>
</div>
</div>
<div class="views-row views-row-2 views-row-even views-row-last alert alert-info fade in">
<div class="views-field views-field-nothing"> <span class="field-content"><a aria-label="close" data-dismiss="alert" class="close" href="#">×</a></span>
</div>
<div class="views-field views-field-title"> <span class="field-content"><a href="/nl/content/treinramp-wetteren">Treinramp in Wetteren</a></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Upvotes: 1
Views: 244
Reputation: 1880
Here it is positioned to the left of your content. It looks like you were targeting the wrong div with your before. I also added a left to give it a bit of space. see the result below
Changed the target div from:
#top-content .block .views-row::before
to:
.views-field-title .field-content:before
Updated the left to:
left: -10px;
The results are below:
.views-field-title .field-content:before {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
color: #f37021;
content: "\e101";
display: inline-block;
font-family: 'Glyphicons Halflings';
font-size: 2em;
font-style: normal;
font-weight: 400;
/*line-height: 1;*/
position: relative;
top: 0.3em;
left:-10px;
}
/*#top-content .block .views-row {
padding-bottom:1.2em;
}*/
#top-content .block .views-row .views-field{
margin-left: 3em;
}
#top-content .block a {
color: #f37021;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<div id="top-content">
<div class="container clearfix">
<div class="clearfix" id="top-content-inside">
<div class="region region-highlighted">
<div class="block block-views contextual-links-region clearfix" id="block-views-alerts-block-1">
<div class="contextual-links-wrapper contextual-links-processed"><a href="#" class="contextual-links-trigger">Configure</a><ul class="contextual-links"><li class="views-ui-edit first"><a href="/en/admin/structure/views/view/alerts/edit/block_1?destination=node/385">Edit view</a></li>
<li class="block-configure last"><a href="/en/admin/structure/block/manage/views/alerts-block_1/configure?destination=node/385">Configure</a></li>
</ul></div>
<div class="content">
<div class="view view-alerts view-id-alerts view-display-id-block_1 view-dom-id-281661d0f4b7c5128ce6ef7abc38dfb1">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first alert alert-info fade in">
<div class="views-field views-field-nothing"> <span class="field-content"><a aria-label="close" data-dismiss="alert" class="close" href="#">×</a></span> </div>
<div class="views-field views-field-title"> <span class="field-content"><a href="/nl/content/wiv-isp-closed-between-1st-and-5th-november">WIV-ISP closed between 1st and 5th of November</a></span> </div> </div>
<div class="views-row views-row-2 views-row-even views-row-last alert alert-info fade in">
<div class="views-field views-field-nothing"> <span class="field-content"><a aria-label="close" data-dismiss="alert" class="close" href="#">×</a></span> </div>
<div class="views-field views-field-title"> <span class="field-content"><a href="/nl/content/treinramp-wetteren">Treinramp in Wetteren</a></span> </div> </div>
</div>
</div> </div>
</div>
</div>
</div>
</div>
</div>
Upvotes: 0
Reputation: 7721
Add float:left
and remove top:0.3em
#top-content .block .views-row::before {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
color: #f37021;
content: "\e101";
display: inline-block;
font-family: 'Glyphicons Halflings';
font-size: 2em;
font-style: normal;
font-weight: 400;
left: 0.35em;
line-height: 1; //uncommented this
float:left; //added this
position: relative;
/*top:0.3em*/ //removed this
}
Upvotes: 2