trying to remove margin-right of my "<ul>" element - html

Im have 3 columns with list items, and I dont understand why my first column (#col1) have a margin-right tha the other columns dont have.
I want that the margin-right is icual for all of my columns but Im not having sucesso doing this.
Do you see where might be the problem?
My jsfiddle with the problem:
http://jsfiddle.net/ritz/r2Y6d/4/
my html:
<div id="body-content">
<h1>Title</h1>
<img src="image1.jpg" width="700px" height="360px" />
<div id="info">
<h1>Info</h1>
<ul id="col1">
<li><i class="fa fa-phone" title="phone"></i>Phone</li>
<li><i class="fa fa-print" title="Fax"></i>Phone</li>
</ul>
<ul id="col2">
<li><i class="fa fa-home" title="adress"></i> Adress</li>
<li ><i class="fa fa-map-marker" title="Map"></i><a class="button" href="#showMap"><span>Show map</span></a></li>
</ul>
<ul id="col3">
<li><i class="fa fa-envelope-o" title="phone"></i>Email</li>
<li><i class="fa fa-envelope-o" title="Email"></i>Email</li>
</ul>
</div>
My css:
#info h1{color:red; font-size:23px; margin-bottom:0;}
#info ul {list-style:none;}
#info ul li a {text-decoration:none; color:#000;}
#col1{float:left; width:295px;font-size:16px; color:#000; margin-right:0;}
#col2{float:left; margin-right:50px;}

Is THIS what you are trying to do?
I removed the width:295px;, margin-right:0; and add #col3{float:left;}

Your first column, #col1, doesn't have a right margin, because you set margin-right:0; to it.
Rather, your uls have a left padding on them, which is set by default by the browser (left margin on IE 7, all other browsers are left padding.)
To remove the default, you need to add two properties to your rule:
#info ul {list-style:none; margin-left: 0; padding-left: 0; }
http://jsfiddle.net/r2Y6d/5/
That will get rid of the left margin.
However, it does look like tabular data. If you don't know already, the most semantic HTML structure for tabular data is a <table>. Or, if it's simple data-value pairs, you could use a definition list (<dl>).

Related

Creating space between fa icon and text

I would like to create a space between my fa icons and text but fa-fw isn't working and neither is.i {margin-left: 10px;}
Html:
<div class="logos1"><i class="fa fa-search">logos</i></div>
HTML
<div class="logos1">
<i class="fa fa-search">
<span class="padding">logos</span>
</i></div>
CSS
.padding{
padding-left:10px;
}
You are writing text between the i tag. This is not a good practice. You can achieve your goal using below code.
i{
margin-right: 10px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css" rel="stylesheet"/>
<div class="logos1"><i class="fa fa-search"></i>logos</div>

My Social icons are pushing my logo away from the center of the page

I am building a responsive website using Bootstrap and Less.
I have put in some social Icons using font awesome which have worked fine.
However, my logo in meant to be in the center and was before I put the social icons in but now I have added them they are pushing my logo to the left.
Here is the html
<header>
<div id="social">
<ul class="pull-right">
<li><i class="fa fa-facebook-official fa-2x"></i></li>
<li><i class="fa fa-twitter fa-2x"></i></li>
<li><i class="fa fa-linkedin-square fa-2x"></i></li>
<li><i class="fa fa-google-plus-square fa-2x"></i></li>
</ul>
</div>
<div class = "logomove">
<div id="logo" class="text-center">
<img src="assets/images/logo.png" alt="Logo" />
</div>
</div>
</header>
And the CSS:
#social {
li {list-style: none; display: inline-block; padding:3px; float:right; color:#brand-primary; }
}
I have also tried positioning the logo 250px across the page to try and center it but it will not work.
Any suggestions much appreciated, I'm really new to this so sorry if I am missing something.
The static positioning of your #social element is pushing the logo away. You have to make either of them absolute to make it not effect the other element.
Try like this:
header{
position:relative;
}
#social {
li {
list-style: none;
display: inline-block;
padding:3px;
float:right;
color:#brand-primary;
position:absolute;
right:0px;
top:0px;
}
}
You might need to adjust the top and right values.

Select a single link to change css properties

I'm using a service which doesn't allow me to modify the code, but I"m able to add my own CSS. I am trying to change the CSS of a specific Link inside a li.
Here is my code:
<div class="kn-menu kn-view view_81" id="view_81">
<ul class="kn-tab-menu kn-grid-6">
<li class="kn-link-1"><span><i class="fa fa-bullseye"></i> I'm On Site</span></li>
<li class="kn-link-2"><span><i class="fa fa-pencil-square-o"></i> 1. Onsite Staff Signature</span></li>
<li class="kn-link-3"><span><i class="fa fa-pencil"></i> 2. Service/Signature</span></li>
<li class="kn-link-4"><span><i class="fa fa-ban"></i> 3. N/A - R</span></li>
<li class="kn-link-5"><span>Add Comments</span></li>
<li class="kn-link-6"><span><i class="fa fa-check"></i> 4. Completed</span></li>
</ul>
</div>
I want to select only the very first list item and tweak the css settings of the link within it - I want to make the background color and text different. Using the following allows me to change somethings but not the actual text within that li.
.kn-link-1 {
}
I also want to make sure that this change only happens for this specific instance where the parent id="view_81".
Can someone help find the right way to select just that
CSS is not the right place where you should change the content, anyway if you have no other choice, you could use the :after selector to do the following trick:
#view_81 > ul > li:nth-child(1) > a > span {
display: none;
}
#view_81 > ul > li:nth-child(1) > a:after {
background-color: red;
content: "your text";
}
<div class="kn-menu kn-view view_81" id="view_81">
<ul class="kn-tab-menu kn-grid-6">
<li class="kn-link-1"><span><i class="fa fa-bullseye"></i> I'm On Site</span>
</li>
<li class="kn-link-2"><span><i class="fa fa-pencil-square-o"></i> 1. Onsite Staff Signature</span>
</li>
<li class="kn-link-3"><span><i class="fa fa-pencil"></i> 2. Service/Signature</span>
</li>
<li class="kn-link-4"><span><i class="fa fa-ban"></i> 3. N/A - R</span>
</li>
<li class="kn-link-5"><span>Add Comments</span>
</li>
<li class="kn-link-6"><span><i class="fa fa-check"></i> 4. Completed</span>
</li>
</ul>
</div>
have you tried:
#view_81 ul li.kn-link-1
or
#view_81 ul li:first-child
To clarify my examples: "#" selector in CSS means "the one with the following ID" and then i'm telling the "ul" that comes after that and then the "li" that comes after that which has this class "kn-link-1" or which is the first item inside the tag (:first-child subselector).
I hope some of them help.
use this style:
li:first-of-type span
{
}
also be sure that your style link is last in your style references. If this does not help, declare your styles with "!important" like here:
li:first-of-type span
{
color:red !important;
}
using the selectors: #view_81 .kn-link-1 a targets the element with id="view_81" and the descendant element with class="kn-link-1" and the a tag inside that to change the background and text color.
#view_81 .kn-link-1 > a {
background: red;
color: yellow;
}
<div class="kn-menu kn-view view_81" id="view_81">
<ul class="kn-tab-menu kn-grid-6">
<li class="kn-link-1"><span><i class="fa fa-bullseye"></i> I'm On Site</span></li>
<li class="kn-link-2"><span><i class="fa fa-pencil-square-o"></i> 1. Onsite Staff Signature</span></li>
<li class="kn-link-3"><span><i class="fa fa-pencil"></i> 2. Service/Signature</span></li>
<li class="kn-link-4"><span><i class="fa fa-ban"></i> 3. N/A - R</span></li>
<li class="kn-link-5"><span>Add Comments</span></li>
<li class="kn-link-6"><span><i class="fa fa-check"></i> 4. Completed</span></li>
</ul>
</div>
I would stylize the css like this:
<style>
#view_81 .kn-link-1{
padding: 50px;
background-color: gray;
}
#view_81 .kn-link-1 a{
text-decoration: none;
}
#view_81 .kn-link-1 span{
color: white;
font-weight: bold;
text-shadow: 1px 2px 2px black;
}
</style>
This css only applies to the class .kn-link-1 within id #view_81.
I added a little basic css for your testing purposes, but you get the point.

Li item on two lines. Second line has no margin

I'm currently working on an unordered list containing list items with taglines. I'm having a problem concerning one list item, which is long enough to take up two lines (See image)
I want it so that the second line is aligned with the first line. This is the HTML code i'm using. I used fontAwesome for the check images.
ul {
width: 300px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<ul class="fa-ul custom-list">
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>This is a list item that actually takes up 2 lines. Looks ugly</li>
</ul>
I already tried to enter multiple in between '2' and 'lines' but that seems like a really bad practice to me. I hope someone can help me with this problem.
This is because the tick is inline content so when the text wraps it will continue to flow as usual.
You can stop this behaviour by taking advantage of text-indent:
The text-indent property specifies how much horizontal space should be left before the beginning of the first line of the text content of an element.
text-indent (https://developer.mozilla.org/en-US/docs/Web/CSS/text-indent)
By supplying a negative text-indent you can tell the first line to shift a desired amount to the left. If you then specify a positive padding-left you can cancel this offset out.
In the following example a value of 1.28571429em is used because it is the width set on the .fa-fw by font-awesome.
ul {
width: 300px;
}
li {
padding-left: 1.28571429em;
text-indent: -1.28571429em;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<ul class="fa-ul custom-list">
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>This is a list item that actually takes up 2 lines. Looks ugly</li>
</ul>
you can just add this to your ul:
ul {
text-indent:-20px;
margin-left:20px;
}
JSFIDDLE
You could remove the check out of the page flow by setting them with position:absolute
ul {
width: 300px;
}
.fa-fw {
position: absolute;
left: -22px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<ul class="fa-ul custom-list">
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>List item on 1 line</li>
<li><i class="fa fa-check fa-fw"></i>This is a list item that actually takes up 2 lines. Looks ugly</li>
</ul>
You can use "display:table" as style for li, and inside create a span with "display:table-cell" styling. Or create corresponding class. Like this:
<li style="display:table"><span style="display:table-cell">text with
all lines indented</span></li>
you can put your text in a div and give float:left to your inner li and div.
ul li{
padding: 10px 0 10px 20px;
text-indent: -1em;
}
add padding and text indent - that moves the text from the li:before.
You can use list-style-position:outside. Do your CSS like this:
ul li {
list-style-position:outside;
... whatever else ...
}
or directly inline:
<li style = 'list-style-position:outside'>stuff </li>
ul li {
display: flex;
flex-direction: row;
}
ul li:before {
font: normal normal normal 14px/1 FontAwesome;
content: "\f054";
margin-right: 7px;
display: flex;
align-items: flex-start;
margin-top: 2px;
}
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<ul><li>Visit the Museum of Modern Art in Manhattan</li>
<li>Visit to Bali with tripraja</li>
<li>Check out Campbell's Soup Cans by Warhol and The Dance (I) by Matisse</li>
<li>Behold masterpieces by Gauguin, Dali, Picasso, and Pollock</li>
<li>Enjoy free audio guides available in English, French, German, Italian, Spanish, Portuguese.</li></ul>

How to make sidebar horizontal for xs devices

I'm using the default CSS that came with bootstrap; also using the bootstrap theme and dashboard CSS.
By default, when on xs devices, the sidebar disappears. Well, this is what i'm using for all my application's main navigation. So, I'd like for it to switch to a horizontal layout on such devices, but I can't find anything online about how to do this.
I scoured the documentation, but it's pretty lousy IMO. There should be a breakdown of all the classes and their uses. I imagine there's a class i can add that will do what I want.
Does anyone know it?
Here's the html:
<div class="container-fluid">
<div class="row">
<div class="col-sm-1 col-md-1 col-lg-1 overflow-fix">
<ul class="nav nav-sidebar">
<li class="icon-center">
</i>
</li>
<li class="icon-center">
<i class="fa fa-users fa-2x" data-toggle="tooltip" data-placement="right" title="Users"></i>
</li>
<li class="icon-center">
<i class="fa fa-building-o fa-2x" data-toggle="tooltip" data-placement="right" title="Accounts"></i>
</li>
<li class="icon-center">
<i class="fa fa-sitemap fa-2x" data-toggle="tooltip" data-placement="right" title="Branches"></i>
</li>
</ul>
</div>
</div>
</div>
Turns out the .css files actually have pretty good comments so I was able to see that .sidebar class had display:none; on it. Then found the media query right under it which gets activated when on larger view ports.
Added the below to my overriding css file, and now it changes to horizontal centered menu when on small screens, then pops back to the sidebar on large screens.
.sidebar {
display:block;
border-bottom: 1px solid #eee;
}
.sidebar ul {
text-align:center;
margin-bottom:0px;
}
.sidebar ul li{
display:inline-block;
}
#media (min-width: 768px) {
.sidebar ul li{
display:block;
}
}
I'm quite new to messing with CSS, so if anyone has a suggestion for how better to format the above code, please don't hesitate to share!
The sidebar has display: none by default. This can be overriden by
.sidebar
{
display:block;
background-color: #f5f5f5;
border-right: 1px solid #eee;
}