Using CSS, how can i target a content which has a class applied on its parent tag? - css

I want to remove the word CART and the link applied to it. How can i target it via CSS
<div class="header-contact">
<i class="fa fa-phone"></i>
<b> +(1)-833-869-6433 </b>
<span class="gap">|</span>
CART
</div>

If you only want to hide the link:
.header-contact .gap + a { display: none; }
<div class="header-contact">
<i class="fa fa-phone"></i>
<b> +(1)-833-869-6433 </b>
<span class="gap">|</span>
CART
</div>
If you also want to hide the divider .gap:
.header-contact [href^=tel] ~ * { display: none; }
<div class="header-contact">
<i class="fa fa-phone"></i>
<b> +(1)-833-869-6433 </b>
<span class="gap">|</span>
CART
</div>

Might want to try .header-contact a:nth-of-type(2) { display: none;} if the structure stays always the same.

Related

How to display elements inline?

Hi i have small problem with CSS that dont know how to resolve.
On my WHMCS template i wanted to implement one element more, and now one element goes in row bellow (Get support). How to fix this?
This is CSS from that element:
.home-shortcuts {
margin: 0;
/*background:#25a2c7;*/
background: #5E35B1;
padding-left: 250px;
margin-top: -60px;
color: #fff
}
and this is code from header.tpl file
<div class="col-sm-12 col-md-8">
<ul>
<li>
<a id="btnOrderHosting" href="cart.php">
<i class="fa fa-headphones"></i>
<p>
Créer une radio <span>»</span>
</p>
</a>
</li>
{if $registerdomainenabled || $transferdomainenabled}
<li>
<a id="btnBuyADomain" href="domainchecker.php">
<i class="fa fa-globe"></i>
<p>
{$LANG.buyadomain} <span>»</span>
</p>
</a>
</li>
{/if}
<li>
<a id="btnOrderHosting" href="cart.php">
<i class="fa fa-hdd-o"></i>
<p>
{$LANG.orderhosting} <span>»</span>
</p>
</a>
</li>
<li>
<a id="btnMakePayment" href="clientarea.php">
<i class="fa fa-credit-card"></i>
<p>
{$LANG.makepayment} <span>»</span>
</p>
</a>
</li>
<li>
<a id="btnGetSupport" href="submitticket.php">
<i class="fa fa-envelope-o"></i>
<p>
{$LANG.getsupport} <span>»</span>
</p>
</a>
</li>
</ul>
</div>
Some advice how to show all in one row?
You can see that your li elements are 24% width. Reduce them to 20% (100 / 5 = 20, and you have five items in your list). That's it.
.home-shortcuts li {
width: 20%;
}
Add
.home-shortcuts{padding-left:0;}
.home-shortcuts .container{width:60%;}
.home-shortcuts li {
width: 20%;
}
make col-md-12 instead of col-md-8 it'll come fine

Adding font awesome icon inline yet superscript with other element

I have two scenarios with similar problems. I'm attempting to add a font awesome icon:
Inline with a text input and 'add on' button, yet superscript (JSFiddle1)
<div>
<div class="input-group">
<input class="form-control">
<span class="input-group-btn">
<button class="btn btn-default" id="copy-link" type="button">
<i class="fa fa-files-o"></i> Copy
</button>
</span>
</div>
<span>
<i class="fa fa-info-circle"></i>
</span>
</div>
Inline with text in a bootstrap panel heading text, but in the top right corner of the heading area (JSFiddle2)
<div class="panel panel-default">
<div class="panel-heading">
<b>
Text
</b>
<span>
<div class="dropdown">
<i class="fa fa-cog dropdown-toggle listing-cog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></i>
</div>
</span>
</div>
<div class="panel-body">
</div>
</div>
Here's how I'd like each to look:
I don't know if this is important, but as a side note:
In the first scenario, the icon has a popover
In the second scenario, the icon has a dropdown
I don't think these have any effect on the layout, so I left out the related code.
For the first problem, your HTML structure is wrong. You need to add the icon inside the input-group DIV. Also to do superscript, you need a CSS class for that. Here is the update code for you:
JS Fiddle
For your second problem, your DIV must be displayed inline with a flotation. Here is the CSS for it:
.dropdown {
display:inline-block;
float:right
}
For your first issue: JS Fiddle
For your second issue as Raed N. said before just add a float:right to your dropdown:
.dropdown { float:right; }

Line up Font Awesome Icons to left of linked Phone No/email

Please could you tell me how to get the phone and email icons - top left on this page - to align to the left of the phone number and email address. The site is set up for RTL display - I'm wondering if that's causing the problem but not sure how to override it. Thank you!!
HTML:
<div class="container">
<div class="pull-left">
<?php
if( get_option('header_phone') )
echo '<i class="fa fa-phone"></i> '. get_option('header_phone') .'';
if( get_option('header_email') )
echo '<i class="fa fa-envelope"></i> '. get_option('header_email') .'';
?>
CSS:
.fa-phone:before {
content: "\e0bf";
float: left;
}
.fa-envelope:before {
content: "\e0bf";
float: left;
}
If I'm understanding the question correctly, the RTL display is kinda reversing the order of things, so the icons need to be after the text they apply to. Then the rendered html is thus -
<div class="pull-left">
545-799518 (972) 00+
<i class="fa fa-phone"></i>
info#photomobil.co.il
<i class="fa fa-envelope"></i>
</div>
Instead of inversing the text/icon order I would do this in more natural way, like:
<div class="pull-left" style="
direction: ltr;
"> <i class="fa fa-phone"></i> 545-799518 (972) 00+<i class="fa fa-envelope"></i> info#photomobil.co.il</div>
You'll se that I have explicitly changed the text direction for the container.

Changing attributes of a span element which is outside a nested span

Question
I want to access the span text and change its color.
How can I do this in the following setup?
Code
<div class="element">
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-play" ng-if="true">button</span>
</button>
<span class="title">Change this color</span>
</div>
Suggestion
span.glyphicon.glyphicon-play[ng-if="true"] span.title {
color:red;
}
This doesn't work unfortunately.
JSFiddle
http://jsfiddle.net/916g3bea/2/
Try this:
span.glyphicon.glyphicon-play[ng-if="true"], span.title {
color:red;
}

How to style icon color, size, and shadow of FontAwesome Icons

How could I style the color, size and shadow of icons from FontAwesome's Icons?
For example, FontAwesome's site will show some icons in white and some in red but won't show the CSS for how to style them that way ...
Given that they're simply fonts, then you should be able to style them as fonts:
#elementID {
color: #fff;
text-shadow: 1px 1px 1px #ccc;
font-size: 1.5em;
}
You can also just add style inline:
<i class="icon-ok-sign" style="color:green"></i>
<i class="icon-warning-sign" style="color:red"></i>
If you are using Bootstrap at the same time, you can use:
<i class="fa fa-check-circle-o fa-5x text-success" ></i>
Otherwise:
<i class="fa fa-check-circle-o fa-5x" style="color:green"></i>
Looks like the FontAwesome icon color responds to text-info, text-error, etc.
<div style="font-size: 44px;">
<i class="icon-umbrella icon-large text-error"></i>
</div>
inyour.css file:
*.icon-white {color: white}
*.icon-silver {color: silver}
inyour.html file:
<a><i class="icon-book icon-white"></i> Book</a>
<a><i class="icon-ok-sign icon-silver"></i> OK</a>
For Size: fa-lg, fa-2x, fa-3x, fa-4x, fa-5x
For Color: <i class="fa fa-link fa-lg" aria-hidden="true"style="color:indianred"></i>
For Shadow: .fa-linkedin-square{text-shadow: 3px 6px #272634;}
There is a really simple way to change the colour of Font Awesome icons.
<!-- Font Awesome insert code -->
<script src="https://use.fontawesome.com/49b98aaeb5.js"></script>
<!-- End -->
<i class="fa fa-thumbs-up fa-5x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up fa-4x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up fa-3x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up fa-2x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up" aria-hidden="true" style="color:#00cc6a"></i>
You can change the hex code to your preference.
NOTE: The text colour will change the icon colour as well unless there is a style="color:#00cc6a" within the i tag.
Using FA 4.4.0 adding
.text-danger
color: #d9534f
to the document css and then using
<i class="fa fa-ban text-danger"></i>
changes the color to red. You can set your own for any color.
http://fortawesome.github.io/Font-Awesome/examples/
<i class="icon-thumbs-up icon-3x main-color"></i>
Here I have defined a global style in my CSS where main-color is a class, in my case it is a light blue hue. I find that using inline styles on Icons with Font Awesome works well, esp in the case when you name your colors semantically, i.e. nav-color if you want a separate color for that, etc.
In this example on their website, and how I have written in my example as well, the newest version of Font Awesome has changed the syntax slightly of adjusting the size.Before it used to be:
icon-xxlarge
where now I have to use:
icon-3x
Of course, this all depends on what version of Font Awesome you have installed on your environment. Hope this helps.
Just target font-awesome predefined class name
in ex:
HTML
<i class="fa fa-facebook"></i>
CSS
i.fa {
color: red;
font-size: 30px;
}
In FontAwesome 4.0, the classes change to 'fa-2x', 'fa-3x'.
Simply you can define a class in your css file and cascade it into html file like
<i class="fa fa-plus fa-lg green"></i>
now write down in css
.green{ color:green}
Please refer to the link
http://www.w3schools.com/icons/fontawesome_icons_intro.asp
<i class="fa fa-car"></i>
<i class="fa fa-car" style="font-size:48px;"></i>
<i class="fa fa-car" style="font-size:60px;color:red;"></i>
<i class="fa fa-car fa-lg"></i>
<i class="fa fa-car fa-2x"></i>
<i class="fa fa-car fa-3x"></i>
<i class="fa fa-car fa-4x"></i>
<i class="fa fa-car fa-5x"></i>
I had the same problem when I tried to use the icons directly from BootstrapCDN (the easiest way). Then I downloaded the CSS file and copied it to my site's CSS folder the CSS file (Described under the 'easy way' in font awesome documentation), and everything started working as they should.
Credit: Can I change the color of Font Awesome's icon color?
(this answer builds on that answer)
(for the bookmark icon, for example:)
inyour.css file:
.icon-bookmark.icon-white {
color: white;
}
inyour.html file:
<div class="icon-bookmark icon-white"></div>
Wrap the i tag in p or span, then you can use bootstrap css class
<p class="text-success"><i class="fa fa-check"></i></p>
For Font Awesome 5 SVG version, use
filter: drop-shadow(0 0 3px rgba(0,0,0,0.7));
As it has been pointed out, font awesome icons are text, consequently you style it using the appropriate CSS attributes. For example:
.fa-twitter-square {
font-size: 15px;
color: red;
}
If, as it happens quite a bit to me, the icon size doesn't change at all, add "!important" to the font-size attribute.
.fa-twitter-square {
font-size: 15px !important;
color: red;
}
For Sizing Icons
Both our Web Fonts + CSS and SVG + JS frameworks include some basic controls for sizing icons in the context of your page’s UI.
you can use like
<i class="fas fa-camera fa-xs"></i>
<i class="fas fa-camera fa-sm"></i>
<i class="fas fa-camera fa-lg"></i>
<i class="fas fa-camera fa-2x"></i>
<i class="fas fa-camera fa-3x"></i>
<i class="fas fa-camera fa-5x"></i>
<i class="fas fa-camera fa-7x"></i>
<i class="fas fa-camera fa-10x"></i>
https://fontawesome.com/how-to-use/on-the-web/styling/sizing-icons
Dynamically change the css properties of .fa-xxx icons:
<li class="nws">
<a href="#NewsModal" class="urgent" title="' + title + '" onclick=""><span class="label label-icon label-danger"><i class="fa fa-bolt"></i></span>'
</a>
</li>
<script>
$(document).ready(function(){
$('li.nws').on("focusin", function(){
$('.fa-bolt').addClass('lightning');
});
});
</script>
<style>
.lightning{ /*do something cool like shutter*/}
</style>
text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
Try to simply use something like fa-lg,fa-2x,fa-3x,fa-4x,fa-5x to increase the icon size relative to their container
for eg:-
I would not advice you to use built in font-awesome styling like the fa-5x etc; for fear they may change it and you would have to keep chainging your application code to meet up with the latest standard. You simply avoid this by giving each font-awesome class you want to style uniformly the same class say:
<i class="fa fa-facebook-square fa-sabi-social-icons" aria-hidden="true"></i>
<i class="fa fa-twitter-square fa-sabi-social-icons" aria-hidden="true"></i>
<i class="fa fa-google-plus-square fa-sabi-social-icons" aria-hidden="true"></i>
Here the class is fa-sabi-social-icons
Then in your css you can the style the fonts using the same css rules you would style a normal font with.
e.g
.fa-sabi-social-icons {
color: //your color;
font-size: // your font-size in px, em or %;
text-shadow: 2px 2px #FF0000;
}
That should get your font-awesome fonts styled
Here is an example how to styling font-awesome:
.arrow i.fa {
color: white !important;
font-size: 2.2rem;
opacity: .3;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="arrow d-none d-md-block">
<i class="fa fa-angle-down"></i>
</div>
That's it.

Resources