#text won't disapear, even with complex CSS selectors [duplicate] - css

This question already has answers here:
Hide text in html which does not have any html tags [duplicate]
(3 answers)
Closed 1 year ago.
I searched a lot here and I do not think there is already an answer.
Only in CSS :
I want the first woocommerce-Price-amount span to be the only one displayed. I can display: none the second but the – which is considered as "#text" by the console won't disapear.
So I have something like :
ARTICLE
160.00€ –
The – is making me crazy...
<span class="price">
<span class="woocommerce-Price-amount amount">
160.00
<span class="woocommerce-Price-currencySymbol">
€
</span>
</span>
–
<span class="woocommerce-Price-amount amount">
1 260.00
<span class="woocommerce-Price-currencySymbol">
€
</span>
</span>
</span>
Every changes I made sure that nothing overwrite my CSS lines.
I tried text-indent: -999px, color: transparent the parent and color: black the child, and more but nothing works...
Thank you !

You could simply set the font-size of the .price span to 0, and then override this in the amount span, as shown in this snippet below:
span.price {
font-size: 0;
}
span.woocommerce-Price-amount.amount {
font-size: initial;
}
span.woocommerce-Price-amount.amount:nth-of-type(2) {
display: none;
}
<span class="price">
<span class="woocommerce-Price-amount amount">
160.00
<span class="woocommerce-Price-currencySymbol">
€
</span>
</span>
–
<span class="woocommerce-Price-amount amount">
1 260.00
<span class="woocommerce-Price-currencySymbol">
€
</span>
</span>
</span>
Of course, this doesn't remove the dash it just, effectively, hides it.

Related

CSS rule to match element not followed by another element of specific class [duplicate]

This question already has answers here:
Is there a "previous sibling" selector?
(30 answers)
Closed 1 year ago.
I have a problem similar to this, but not identical to it...
In my case I have the following layout:
<span class="title">Title1:</span>
<span class="content">Content1</span>
<span class="title">Title2:</span>
<span class="content">Content2</span>
<span class="title">Title3:</span>
<span class="content">Content3</span>
<span class="title">Title4:</span>
<span class="content">Content4</span>
Which is displayed like this:
Title1: Content1
Title2: Content2
Title3: Content3
Title4: Content4
with the help of the following CSS
span.title{
font-weight: bold;
}
span.content::after {
content: "\a";
white-space: pre;
}
However, there will be a case where the first span.title will be orphan - not followed by a span.content but rather by another span.title. In that special case, I want the orphan span.title to be in its own line... So it will be like this:
Oprhan title
Title1: Content1
Title2: Content2
Title3: Content3
Title4: Content4
What's the correct rule to cover that :not() case?
I've tried quite many variations like the one below, but non seems to work...
span.title::after + :not(span.content) {
content: "\a";
white-space: pre;
}
Thanks a lot in advance!
EDIT: Basically, the more I think about this, the more I suspect it can't be solved in CSS... + operator selects the element after it, not before it...
Could add the line break before the next line instead of after the orphaned title perhaps.
span.title{
font-weight: bold;
}
span.content::after {
content: "\a";
white-space: pre;
}
span.title + :not(span.content)::before {
content: "\a";
white-space: pre;
}
<span class="title">Orphan Title</span>
<span class="title">Title1:</span>
<span class="content">Content1</span>
<span class="title">Title2:</span>
<span class="content">Content2</span>
<span class="title">Title3:</span>
<span class="content">Content3</span>
<span class="title">Orphan Title2</span>
<span class="title">Orphan Title3</span>
<span class="title">Title1:</span>
<span class="content">Content1</span>
<span class="title">Title2:</span>
<span class="content">Content2</span>
<span class="title">Title3:</span>
<span class="content">Content3</span>

Why cant I remove this border with CSS? [duplicate]

This question already has answers here:
How can I override inline styles with external CSS?
(7 answers)
Closed 3 years ago.
I have two questions I seek your help with:
I am trying to remove the grey border using CSS but can't seem to remove it.
My code is:
<p class="product woocommerce add_to_cart_inline " style="border:4px solid #ccc; padding: 12px;">
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">$</span>
29.00
</span>
<a href="?add-to-cart=511" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart"
data-product_id="511" data-product_sku="plan1" aria-label="Add “Plan 1” to your cart" rel="nofollow">
Add to cart
</a>
</p>
My CSS is:
p.product.woocommerce.add_to_cart_inline {
border:0px;
}
span.woocommerce-Price-amount.amount {
display:none
}
Here is my JSFiddle.
Can someone please let me know why my CSS code does not work?
In Chrome developer tools, is there a way to easily copy the CSS selector?
For example, after pointing out that this is the selector.
Is there a way to easily copy the "p.product.woocommerce.add_to_cart_inline"?
Right now I type it out manually myself. I am pretty sure that there should be a way to copy it and paste it directly?
change your HTML code you have inline css for border in html p tag
<p class="product woocommerce add_to_cart_inline " padding: 12px;"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>29.00</span>Add to cart</p>
or you can add important to css like this:
p.product.woocommerce.add_to_cart_inline {border:none!important;}
Remove border css style from style attribute
<p class="product woocommerce add_to_cart_inline " style="padding: 12px;"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>29.00</span>Add to cart</p>
add !important
p.product.woocommerce.add_to_cart_inline {border:none!important;}
It's not working because of css specificity rules
You are adding border style inline in p tag which has more specificity than css selector.
To fix this, remove the border style from the inline and apply it using another css selector.
Here is updated fiddle
p.product.woocommerce {
border: 4px solid #ccc;
padding: 12px;
}
p.product.woocommerce.add_to_cart_inline {
border: 0px;
}
span.woocommerce-Price-amount.amount {
display: none
}
<p class="product woocommerce add_to_cart_inline"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>29.00</span><a href="?add-to-cart=511" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="511"
data-product_sku="plan1" aria-label="Add “Plan 1” to your cart" rel="nofollow">Add to cart</a></p>

Pseudo elements don't appear to work in Salesforce lightning CSS

I have a list group that holds a bunch of attributes, but when I clarify that the last element within that group hold a margin of 0, the output doesn't match.
The Salesforce HTML:
<aura:iteration items="{!v.IdeasList}" var="idea">
<li class="list-group-item">
<a href="{!v.ideaDetailPath + idea.Id }" class="anchorLink">
<div class="prodname">{!idea.Title}</div>
</a>
<div class="ideaInfo">
<span class="points">{!idea.VoteTotal} points </span>
<span style="padding-right:24px;">
<span class="status">
{!idea.Status}
</span>
</span>
<span class="createdDate"><ui:outputDate value="{!idea.CreatedDate}"/></span>
<!--span class="slds-avatar slds-avatar_circle slds-avatar_small">
<img src='{!idea.CreatorSmallPhotoUrl}'/>{!idea.CreatorName}</span>
<span class="slds-text-title_bold">
<a class="profileName" href="javascript:void(0)"
id="profile-link"
data-createdByValue="{!idea.CreatedById}"
onclick="{!c.openProfileWindow}">
{!idea.CreatorName}</a></span-->
<a class="slds-text-title_bold profileName" id="profile-link" data-createdByValue="{!idea.CreatedById}" href="javascript:void(0);" onclick="{!c.openProfileWindow}">
<span class="slds-avatar slds-avatar_circle slds-avatar_small slds-m-right_x-small">
<img src="{!idea.CreatorSmallPhotoUrl}"/>
</span>{!idea.CreatorName}
</a>
</div>
<div class="slds-border_bottom">
</div>
</li>
</aura:iteration>
The Salesforce CSS:
.THIS .list-group-item {
font-size: 12px;
list-style: none;
width: 100%;
margin-bottom:24px;
}
.THIS .list-group-item:last-child{
margin-bottom:0;
}
Does that mean pseudo elements (specifically last-child in this case) don't work in Salesforce Lightning CSS?
It seems that the only thing that works is :nth-last-child(2) - because for some reason, :last-child doesn't acknowledge that the last item is actually the last item.
I did a search within the HTML to check that there was no other element after the element I was hoping to edit via CSS, but there wasn't. Seems as though this is a salesforce bug? Anyway,s :nth-last-child(2) worked instead of :last-child

Conditionally apply a CSS [duplicate]

This question already has an answer here:
Apply style to element, only if a certain element exists next to it
(1 answer)
Closed 5 years ago.
I have a style defined that needs to be applied only if there is an icon, but not if there isn't.
The html structure with an icon is as follows:
<li class="g-menu-item g-menu-item-226 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/services/visas">
<i class="fa fa-id-badge"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">Visas</span>
</span>
</a>
</li>
The structure without an icon is as follows:
<li class="g-menu-item g-menu-item-232 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/destinations/australia/adelaide">
<span class="g-menu-item-content">
<span class="g-menu-item-title">Adelaide</span>
</span>
</a>
</li>
The SCSS I have worked fine on items with an icon. It moves the span with the class g-menu-item-title to the right by 1.25rem and up by 1rem:
.aside-nav {
.g-menu-item-container {
.g-menu-item-content {
margin-left: 1.25rem !important;
margin-top: -1rem !important;
}
}
}
However, when there is no icon, it makes the menu items in the sidebar squished into each other.
How do I change this SCSS so that it only applies to menu items in the aside where the item has an icon, but not when there isn't an icon.
You can use an Adjacent sibling selector,
It'll let you target an element that is next to another element:
i + .g-menu-item-content {
margin-left: 1.25rem !important;
margin-top: -1rem !important;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<ul>
<li class="g-menu-item g-menu-item-232 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/destinations/australia/adelaide">
<span class="g-menu-item-content">
<span class="g-menu-item-title">Adelaide</span>
</span>
</a>
</li>
<li class="g-menu-item g-menu-item-226 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/services/visas">
<i class="fa fa-id-badge"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">Visas</span>
</span>
</a>
</li>
</ul>

span display block makes text after the span drop as well

HTML:
<p>
<a href="#">my
<span>favorites</span>
</a>
(13)
</p>
I want "favorites" to drop after "my", and then to separately style "(13)", which should be on the same line as "favorites".
I tried with the above markup and the following CSS but (13) also drops:
p span a { display: block; }
(13) should stay on the same line as "favorites" so it looks like
my
favorites(13)
How about this?
my<br>favorites<span>(13)</span>
The longer version (more flexibility)
If you don't want a line break, you could use a block element. Now, since block elements aren't allowed inside inline elements (<a>), you should use span tags and style them as block elements.
<a href="#">
my
<span class="second-line">
favorites <span class="count">(13)</span>
</span>
</a>
And the CSS:
a .second-line {
display: block;
}
a .count {
color: #888888;
}
Would this work for you?
<p>
<a href="#">my
<p>favorites <span>(13)</span></p>
</a>
</p>

Resources