css: decorating a div with ::after content without wrapping - html

I've been playing around for a while to get a list to have the main list text left aligned in a content column with a "+" sign right aligned on the same line. I have this working perfectly in firefox, only to discover that lines which are longer than a single line (and therefore will have an ellipsis overflow) are wrapping the "+" sign in IE and chrome.
The example i have extracted from my project is at https://jsfiddle.net/qo65Lg2n/2/. Since this is an extract some things like the category numbering isn't showing correctly.
Is there another way of approaching this that will work in all three major browsers?
Thanks
html:
<div style="width: 1000px; text-align: center; margin: auto">
<div class="sfexpandableListWrp">
<ol class="sflistList">
<li class="sflistItemTitle">
<a class="sflistItemToggleLnk" href="#">
this is a short list title
</a>
</li>
<li class="sflistItemTitle">
<a class="sflistItemToggleLnk" href="#">
this is a really really really really really really really really really really really really really really long list title
</a>
</li>
<li class="sflistItemTitle">
<a class="sflistItemToggleLnk" href="#">
something
</a>
</li>
</ol>
</div>
</div>
css:
.sfexpandableListWrp
{
max-width: 500px;
text-align: left;
}
.sfexpandableListWrp .sflistList
{
margin-bottom: 23px;
list-style-type: none;
}
.sfexpandableListWrp .sflistItemTitle
{
font-size: 1em;
font-weight: bold;
float: left;
width: 100%;
background-color: #1BB2A0;
border-radius: 8px;
line-height: 3.7em;
margin-bottom: 1em;
}
/* List item toggle link */
.sfexpandableListWrp .sflistItemToggleLnk
{
padding-left: 15px;
color: white;
display: block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
padding-right: 4em;
}
.sfexpandableListWrp .sflistItemToggleLnk::before
{
content: "Category " counter(category-counter) ": ";
color: black;
font-family: "VAGRoundedBT-Regular";
counter-increment: category-counter;
}
.sfexpandableListWrp .sflistItemToggleLnk::after
{
content: "+";
color: white;
float: right;
clear: right;
font-size: 2em;
background-color: #88CEB4;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
padding: 0 0.5em;
margin-right: -2em;
}

Use position absolute may help you.
first,change the ::after element to position:absolute and delete margin-right,float attribute
.sfexpandableListWrp .sflistItemToggleLnk::after
{
position:absolute;
top:0;
right:0;
content: "+";
color: white;
font-family: "VAGRoundedBT-Regular";
font-size: 2em;
background-color: #88CEB4;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
padding: 0 0.5em;
}
second add position:relative to the parent .sflistItemToggleLnk
.sfexpandableListWrp .sflistItemToggleLnk {
padding-left: 15px;
color: white;
display: block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
padding-right: 4em;
position:relative;
}
I hope that is what your want

.sfexpandableListWrp .sflistItemToggleLnk {
padding-left: 15px;
color: white;
display: block;
/* white-space: nowrap; */
text-overflow: ellipsis;
overflow: hidden;
padding-right: 4em;
}
try this . It may helps you..

Related

ul li timetable elements overlapping

Making a responsive timetable which switches to a list format for mobile, with Weekdays acting as headers and relevant sessions being listed below.
I've encountered a problem where li elements overlap. Despite experimenting with position and display values, I can't figure out how to counteract this overlap.
Any help would be appreciated.
.smallTableContainer {
position: relative;
display: none;
height: auto;
overflow: hidden;
}
.weekdayHeader {
background: #bc4b51;
color: #efefef;
font-size: 18pt;
padding: 10px 0px;
}
.sessions {
padding: 0;
}
.className {
float: left;
display: inline-block;
color: #1e1e1e;
font-size: 13pt;
padding-left: 10px;
}
.classTime {
float: right;
display: inline-block;
color: #1e1e1e;
font-size: 12pt;
padding-right: 10px;
}
<div class="smallTableContainer">
<h3 class="weekdayHeader">Monday</h3>
<ul class="sessions">
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 5-7
<br>[ SPACES AVAILABLE ] </div>
<div class="classTime">
<br> 16.15pm - 17.00pm
</div>
</li>
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 8-12
<br>[ SPACES AVAILABLE ]
</div>
<div class="classTime">
<br> 17.00pm - 17.45pm
</div>
</li>
</ul>
</div>
If I understand your desired result correctly, you want the events and times to disaply on individual lines. In order to do this, all you're looking for is cleart: both on your .sessions li. In addition to this, you'll probably want to add a bit of spacing between each event, which can be done by adding margin-top to the (rather complex) .sessions li:not(:first-of-type) .className selector. This ensures that the margin will be applied to all of the listings apart from the first one.
This can be seen in the following:
.smallTableContainer {
position: relative;
/*display: none;*/
height: auto;
overflow: hidden;
}
.weekdayHeader {
background: #bc4b51;
color: #efefef;
font-size: 18pt;
padding: 10px 0px;
}
.sessions {
padding: 0;
}
.sessions li {
clear: both;
}
.className {
float: left;
display: inline-block;
color: #1e1e1e;
font-size: 13pt;
padding-left: 10px;
}
.classTime {
float: right;
display: inline-block;
color: #1e1e1e;
font-size: 12pt;
padding-right: 10px;
}
.sessions li:not(:first-of-type) .className {
margin-top: 20px;
}
<div class="smallTableContainer">
<h3 class="weekdayHeader">Monday</h3>
<ul class="sessions">
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 5-7
<br>[ SPACES AVAILABLE ] </div>
<div class="classTime">
<br> 16.15pm - 17.00pm
</div>
</li>
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 8-12
<br>[ SPACES AVAILABLE ]
</div>
<div class="classTime">
<br> 17.00pm - 17.45pm
</div>
</li>
</ul>
</div>

CSS3/HTML5: Hamburger menu displayed with fixed positioning not displaying

I created a hamburger dropdown menu which was working until recently, which I'm guessing is due to a browser update in Chrome. So I'm looking into improving the stability of it across browsers. Now it does not display at all. In Chrome is looks like it is positioned correctly via the dev tools. (My website if anyone wants to inspect: http://alexandstein.com/main/dndchar ) I tried checking the Z-index, but it seems I've already set that to 30.
Here is the HTML for the navigation, which includes the hamburger menu.
<nav id="navigation">
<ul>
<span id="logo">
<li>Alexworks</li>
</span>
<span id="links">
<li>About-Meta</li><li>Projects</li><li>Music</li> </span>
<span id="hamburgerSection">
<li id="hamburger" class="menuFocused"><img src="http://alexandstein.com/resources/images/icons/hamburger.png" alt="Menu" class="iconSmall">
</li>
</span></ul>
<div id="hamburgerMenu" style="display: block;">
<div id="controls">
<img height="35" width="35" class="textControls" id="smallTextButton" src="/resources/images/icons/TextIconSmall.png" alt="Small">
<img height="35" width="35" class="textControls" id="medTextButton" src="/resources/images/icons/TextIconMed.png" alt="Medium">
<img height="35" width="35" class="textControls" id="largeTextButton" src="/resources/images/icons/TextIcon.png" alt="Large">
</div>
<p>Table of Contents</p><p>
</p><ul id="tableOfContents"><li>Preface</li>
<li>Instructions</li>
<li>DnD Character Manager</li>
<li>Notes</li>
</ul>
</div>
</nav>
The pertinent CSS:
#hamburgerMenu{
background-color: rgba(30,30,30, 0.9);
color: white;
padding-top: 5px;
padding-bottom: 5px;
padding: 9px;
width: 230px;
position: fixed;
top: 35px;
right:0%;
z-index: 30;
font-size: 12pt;
border-left-style: solid;
border-left-color: rgba(100,100,100, 0.5);
border-left-width: 4px;
overflow-x: hidden;
.textControls{
width: 35px;
height:35px;
margin-right: 5px;
display: inline;
background-color: white;
color: black;
text-decoration: underline;
text-align: center;
opacity: 0.5;
}
.textControls:hover{
opacity: 1.0;
}
}
Here is the navigation CSS if anyone wants to check the parent element for any quirks:
/*NAVIGATION BAR*/
#navigation{
min-width: #MIN-WIDTH;
list-style-type: none;
text-align: center;
width: 100%;
margin: 0%;
padding: 0%;
padding-top: .3em;
position: fixed;
top: 0px;
right:0px;
z-index: 10;
background-color: black;
height: 35px;
overflow-y: hidden;
overflow-x: scroll;
ul{
margin: 0%;
padding: 0%;
padding-top: 0%;
}
a{
margin-top: 5px;
margin-right: .4em;
color: #HEADER_TEXT;
}
a:visited{
color: #999;
}
a:hover{
color: #bbb;
}
li{
display: inline-block;
width: 13em;
height: 1.8em;
border-bottom-style: solid;
border-bottom-color: red;
}
li:hover{
background-color: #333;
}
.iconSmall{
width: 30px;
height:30px;
}
#logo{
display: inline-block;
text-align: left;
width: inherit;
float:left;
letter-spacing: 5px;
}
#links{
display: inline-block;
right: 0px;
}
#hamburger{
width: 30px;
border-bottom-style: none;
float: right;
}
}
The problem is the overflows on your #navigation element. With these overflows, you are telling the browser to not show anything outside the scope of the #navigation element.
The most likely reason why it was working before and isn't now is overflow-x and overflow-y are still experimental (and also not backward compatible). I'd recommend taking them out.
Picture with the chrome inspector changes:

A tags have height but cannot be clicked

I am having a problem where I have li tags wrapped by a tags and they both have a height but the links do not work. I am confused as to why but here is a fiddle and my code.
<div id="homepageContentLeft">
<ul>
<li><span>Register Here</span></li>
<li><span>Race Map</span></li>
<li><span>Donate</span></li>
<a class="last" href="http://cff.org" target="_blank"><li class="last" ><img src="pictures/cfflogo1.png" alt="CFF" /></li></a>
</ul>
</div>
<div id="slidesContainer">
<div href="register.php" id="freeTShirt">Free T-shirt W/ Registration.</div>
<div id="slides">
<img src="pictures/pic1.jpg" alt="Race Beginning"/>
<img src="pictures/pic2.jpg" alt="Race Beginning"/>
<img src="pictures/pic3.jpg" alt="Race Beginning"/>
<img src="pictures/pic4.jpg" alt="Race Beginning"/>
</div>
</div>
And here is my scss
#homepageContent {
width: $pageWidth;
margin: 1% auto;
margin-bottom: 0;
overflow: hidden;
#homepageContentLeft, #slides {
float: left;
}
#homepageContentLeft {
width: 30%;
text-align: center;
ul {
list-style: none;
margin-top: 0px;
margin-right: 15px;
margin-left: 0px;
padding-left: 0px;
margin-bottom: 0px;
li:first-of-type {
margin-top: 0px;
//background-image: -webkit-linear-gradient(top, #A21945, #7A0026);
}
a {
overflow: hidden;
cursor: pointer;
display: block;
height: 85px;
margin-bottom: 17px;
li {
height: 85px;
vertical-align: middle;
font-size: 1.6em;
background-color: #0099ff;
color: white;
border-radius: 10px;
cursor: pointer;
span {
display: inline-block;
vertical-align: middle;
line-height: 85px;
width: 100%;
}
img {
display: block;
max-width: 100%;
height: 90%;
width: auto/9;
margin: 0 auto;
}
}
}
li:hover {
//background-image: -webkit-linear-gradient(top, #666666, #3d3d3d);
}
li.last, a.last {
margin-bottom: 0px;
}
}
}
http://jsfiddle.net/keS96/
Took a quick glace at it and saw the you have a lot of questionable / wrong markup.
Put the links inside the li, not the li inside the links.
<ul>
<li>
Linktext
</li>
</ul>
Assign the style via the CSS, rather than assigning them inside the markup. The markup is for markup, the Stylingsheet is for styling.
To answer your question:
You assigned float: left; to the homepageContentLeft element. The slidesContainer does not have a float attribute and its width therefore "lays over" the Navigation. Assign a float element towards it and you'll fix your problem.
Your problem doesn't have anything to do with the height of your list items or links. The problem is that #slidesContainer is rendering over everything and blocking the click events. When you manually remove that node from the DOM the links work as expected.
Your "a" tags need to be inside of your "li" tags.

List Item First Indentation Not Lining Up

In each list item I have a text box within a div element.
<html>
<body>
<!-- Window -->
<div id="sample_container_id">
<div class="bucket" id="defaultBucket">
<h3>Default Bucket</h3>
<input type="button" value="Add" class="button">
<div class="innerBucket">
<ul id="tasks">
<li>
<div class="TaskDiv">
<input type="text" class="TaskTextInput">
</div>
</li>
<li>
<div class="TaskDiv">
<input type="text" class="TaskTextInput">
</div>
</li>
<li>
<div class="TaskDiv">
<input type="text" class="TaskTextInput">
</div>
</li>
</ul>
</div> <!-- innerBucket -->
</div> <!-- defaultBucket -->
</div>
</body>
</html>
This is the result:
body
{
background-color: #F8F8F8;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
font-weight: normal;
line-height: 1.2em;
margin: 15px;
}
h1, p
{
color: #333;
}
#sample_container_id
{
width: 100%;
height: 400px;
position: relative;
border: 1px solid #ccc;
background-color: #fff;
margin: 0px;
}
.innerBucket
{
width: 290px;
height: 355px;
margin-top: 40px;
margin-left: 5px;
position: relative;
background-color: white;
}
.bucket
{
width: 300px;
height: 400px;
background-color: #ddd;
position: absolute;
}
.bucket h3
{
float: left;
padding-left: 10px;
padding-top: -10px;
}
.bucket ul
{
margin: 0;
padding-left: 30px;
position: relavtive;
list-style: none;
}
.bucket ul li
{
margin: 0;
padding: 0;
text-indent: 0.5em;
margin-left: -0.5em;
display: block;
position: relative;
}
.bucket .button
{
background-color:#fbb450;
border:1px solid #c97e1c;
float: right;
margin: 5px;
display:inline-block;
color:#ffffff;
font-family:Trebuchet MS;
font-size:17px;
font-weight:bold;
padding:2px 11px;
text-decoration:none;
text-shadow:0px 1px 0px #8f7f24;
}
Result
As you may notice the first item is indented, and I would like the list items to all be aligned on the left. How do I fix this with the CSS (there probably is a lot of things wrong with my CSS, I was trying everything)?
EDIT
I added some more code. You should be able to replicate the problem now.
I didn't want to post a wall of code :)
Solution
I found the solution to the problem. The problem was actually the <h3> element. The bottom margin was forcing the first element off to the side.
Adding this fixed the problem:
.bucket h3
{
...
margin-bottom: 0;
}
Don't float the divs, if you do make sure to clear them or you get
what FakeRainBrigand got in his pen.
Spell relative right For that
matter take the positioning out of that code, it's pointless.
list items by definition are block elements, you don't need to declare
that either.
Close your input tags.
The float is likely the issue, pushing the divs against some invisible element.
.TaskDiv
{
margin: 0;
padding: 0;
}
ul
{
margin: 0;
padding-left: 30px;
list-style: none;
}
ul li
{
margin: 0;
padding: 0;
text-indent: 0.5em;
margin-left: -0.5em;
}
Example: http://jsfiddle.net/calder12/Yw4tB/
I found the solution to my own problem. The issue was the margin of the header forcing the div over (see the end of my question). The solution was simple once I figured that out.
Simply adding this to the h3 styling fixed my problem:
margin-bottom: 0;

CSS Float does not stretch Div Height

I have had this problem for a long time when working with HTML/CSS and Floats.
In the image you can see I have a Box Div that is Floated left as there is many of these Boxes. Inside the Box I have a <UL> List. The List items <li> are also Floated left.
As you can see in the image, the List items do not make the Box Div that they are inside of Expand. I have tried several thing without much luck and was hoping someone with more experience could help? I cannot set a fixed height on the Box Div as the number of icons is always different and it needs to expand to fix them.
Live demo: http://jsfiddle.net/jasondavis/u5HXu/
<div class="module-box">
<div class="module-box-title">
<h4><i class="icon-cogs"></i>Admin Settings</h4>
<div class="tools">
-
</div>
</div>
<div class="module-box-body" style="display: block;">
<ul>
<li>
<a href="#">
<img src="http://cp.codedevelopr.com/modules/password_assistant/assets/icon.png" border="0">
<span class="module-icon password_assistant"></span>
</a><br>
Change<br>Password
</li>
<li>
<a href="#">
<img src="http://cp.codedevelopr.com/modules/password_assistant/assets/icon.png" border="0">
<span class="module-icon password_assistant"></span>
</a><br>
Change<br>Password
</li>
<li>
<a href="#">
<img src="http://cp.codedevelopr.com/modules/password_assistant/assets/icon.png" border="0">
<span class="module-icon password_assistant"></span>
</a><br>
Change<br>Password
</li>
</ul>
</div>
</div>
CSS
/* Modules homepage */
.module-box {
margin: 0px 0px 25px 25px;
padding: 0px;
float: left;
width: 464px;
}
.module-box-title {
margin-bottom: 0px;
padding: 8px 10px 2px 10px;
border-bottom: 1px solid #eee;
color: #fff !important;
background-color: #333;
height: 51px;
line-height: 45px;
border-radius: 3px 3px 0 0;
}
.module-box-title h4 {
display: inline-block;
font-size: 18px;
font-weight: 400;
margin: 0;
padding: 0;
margin-bottom: 7px;
}
.module-box-title .tools {
display: inline-block;
padding: 0;
margin: 0;
margin-top: 6px;
float: right;
}
.module-box-title .tools a {
font-size: 31px;
color: #fff;
text-decoration: none;
line-height: 29px;
}
.module-box-body {
background-color: #fff;
border: 1px solid #ccc;
border-top: 0;
padding: 10px;
clear: both;
}
.module-box-body a {
font-family: 'Source Sans Pro', sans-serif;
font-size: 11px;
color: #888;
text-decoration: none;
}
.module-box-body li {
float: left;
margin: 0 12px 0 0;
list-style: none;
}
You need to clear your floats using a clearfix or clearing element.
Method #1 clearfix
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
Then you add the class on the containing element
<div class="module-box-body clearfix" style="display: block;">
http://jsfiddle.net/u5HXu/8/
Method #2 Clearing Element
.clear {
clear: both;
}
Then you add the following HTML after your floated elements.
<div class="clear"></div>
http://jsfiddle.net/u5HXu/9/
You can use the overflow: hidden trick on the parent container (..module-box-body) ;) fixes everything.
http://jsfiddle.net/teddyrised/ct6gr/
Change your .module-box-body li to
.module-box-body li {
display: inline-block;
margin: 0 12px 0;
list-style: none;
}
Updated fiddle.
Try applying overflow:auto to the container, the one whose height you want to resize based on the height of its contents (the floated items).
I'd add a jsfiddle link but it's not been working at all for me recently. :/