there were so many questions about that but none of them are helpful for me. I want normal links blue and underlined while the titles for articles should be red and without underline. This is the code:
a {
color: #337ab7;
text-decoration: underline;
}
.field.field--name-title{
color: #fffff0;
text-decoration: none;
}
I tried combine like: a.field.field--name-title and .field.field--name-title a but it doesn't work.
#EDIT
Adding HTML, this is the DIV with the article:
<div class="views-row">
<article role="article" about="/de/link-test" class="node node--type-blog-entry node--promoted node--view-mode-teaser clearfix">
<div class="node__container">
<div class="node__main-content clearfix">
<header class="node__header">
<h2 class="node__title">
<a href="/de/link-test" rel="bookmark"><span class="field field--name-title field--type-string field--label-hidden">LINK TEST</span>
</a>
</h2>
</header>
<div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>tu jest link www.example.com</p>
</div>
<div class="node__links">
<ul class="links inline"><li class="node-readmore">Weiterlesen<span class="visually-hidden"> über LINK TEST</span></li></ul> </div>
</div>
</div>
</article>
</div>
You are targeting the wrong selector. .field.field--name-title is the span inside the anchor tag. Given the markup you provided, try this:
a {
color: #337ab7;
text-decoration: underline;
}
.node__title a {
color: #fffff0;
text-decoration: none;
}
Better still would be to give the anchor tag a class and target that.
If the link (i.e. a tag) does not have the .field.field--name-title classes itself, but is inside those elements, you'd have to write
.field.field--name-title a {
color: #fffff0;
text-decoration: none;
}
That would be the case if the HTML is for example
<li class="field field--name-title">
Title
</li>
If this doesn't apply, you really should post the relevant HTML code, even if you can't edit it, since we have to see the HTML structure in order to get the correct CSS selectors...
ADDITION AFTER HTML CODE HAVING BEEN ADDED:
In this case the selector should be
a.field.field--name-title
If that doesn't work, there might already be a rule with higher specifity in the CSS of your site, so you can extend it to
a.field.field--name-title.field--type-string.field--label-hidden { ... }
And if that still isn't enough, you can add some more, like
.node__container .node__main-content .node__header a.field.field--name-title.field--type-string.field--label-hidden { ... }
a {
color: #337ab7;
text-decoration: none;
}
.node__title a {
color: #fffff0;
text-decoration: none;
}
<div class="views-row">
<article role="article" about="/de/link-test" class="node node--type-blog-entry node--promoted node--view-mode-teaser clearfix">
<div class="node__container">
<div class="node__main-content clearfix">
<header class="node__header">
<h2 class="node__title">
<a href="/de/link-test" rel="bookmark"><span class="field field--name-title field--type-string field--label-hidden">LINK TEST</span>
</a>
</h2>
</header>
<div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>tu jest link www.example.com</p>
</div>
<div class="node__links">
<ul class="links inline"><li class="node-readmore">Weiterlesen<span class="visually-hidden"> über LINK TEST</span></li></ul> </div>
</div>
</div>
Related
How can I use one css code snipped for more ids? The code I tried doesn´t work. My goal is that when the user hovers over the text with the id "txtBurgerista", all the texts with the other ids should be white. But only when the user hovers id "txtBurgerista".
#txtBurgerista:hover ~ #txtFitGreen, #txtMore {
color:white
}
<div class="bigDiv2">
<h2 id="txtBurgerista" class="txtBurgerista">Burgerista</h2>
<h2 id="txtFitGreen">Fit Green Mind</h2>
<h2 id="txtNinjas">Ninjas</h2>
<h2 id="txtReinhartshuber">Reinhartshuber</h2>
<h2 id="txtLakhis">Lakhi´s</h2>
<h2 id="txtIndigo">my Indigo</h2>
<h2 id="txtMore">And more</h2>
</div>
You can do this:
#txtBurgerista:hover,
#txtFitGreen,
#txtMore {
color:white
}
I am unsure if you intended to use the hover on the first one, but if not you and do it like this instead:
#txtBurgerista,
#txtFitGreen,
#txtMore {
color:white
}
To make the style apply only on hover to all the IDs:
#txtBurgerista:hover,
#txtFitGreen:hover,
#txtMore:hover {
color:white
}
.bigDiv2:hover > h2:not(:hover) {
color:white
}
<div class="bigDiv2">
<h2 id="txtBurgerista" class="txtBurgerista">Burgerista</h2>
<h2 id="txtFitGreen">Fit Green Mind</h2>
<h2 id="txtNinjas">Ninjas</h2>
<h2 id="txtReinhartshuber">Reinhartshuber</h2>
<h2 id="txtLakhis">Lakhi´s</h2>
<h2 id="txtIndigo">my Indigo</h2>
<h2 id="txtMore">And more</h2>
</div>
Try this:
#txtBurgerista:hover,
#txtFitGreen,
#txtMore {
color:white
}
I know this looks very simple, but I have been trying to figure out a solution for an hour now. I have an "a" element with text and an image inside. The problem is that the image goes below the text, and I want them lined up.
a {
text-decoration: none;
color: #fff;
}
a:hover {
color: #ff5c33;
text-decoration: none;
cursor: pointer;
}
#nav-user-logo{
max-height: 16px;
}
<!-- Header right part -->
<div class="dropdown">
<a>
User123
<img src="Images/Icons/user.svg" id="nav-user-logo" alt='User123'>
</a>
<div class="dropdown-content user-dropdown-content" >
<a>AW Admin</a>
<a>Account Settings</a>
<a>Change Password</a>
<a>Logout</a>
</div>
</div>
I didn't have the issue myself but you can do
#nav-user-logo {
max-height: 1em;
display: inline;
}
to guarantee it is inline with the text.
By defect, any browser, with your css will display the image side by side as, I think, you want:
example with your code:
a {
text-decoration: none;
}
a:hover {
color: #ff5c33;
text-decoration: none;
cursor: pointer;
}
#nav-user-logo{
max-height: 16px;
}
<div class="dropdown">
<a>
User123
<img src="https://www.ajvs.com/redirect/5/Agilent_IMG300_UHV_R0343301_1,8926cf9ec9ce009a52f3ea8866b07f5f" id="nav-user-logo" alt='User123'>
</a>
<div class="dropdown-content user-dropdown-content">
<a>AW Admin</a>
<a>Account Settings</a>
<a>Change Password</a>
<a>Logout</a>
</div>
</div>
Probably, you have some kind of "reset" css sheet that is turning all your images as display:block It's quite common in many wordpress themes. You may need to overwrite these css adding img {display:inline-block} or similar rule. Calling to the id image or class to not break your whole theme.
Turns out the issue was something super simple. This code is in a header, on the right side, and the "a" element was too small to display the code and image side by side. I fixed it with the following:
<!-- Header right part -->
<div class="dropdown">
<a style="display:inline-block; width: 150px;">
User123
<img src="Images/Icons/user.svg" id="nav-user-logo" alt='User123'>
</a>
<div class="dropdown-content user-dropdown-content" >
<a>AW Admin</a>
<a>Account Settings</a>
<a>Change Password</a>
<a>Logout</a>
</div>
</div>
In one of my page I can have two situation.
The first, in case no event found
<div class="mec-wrap mec-skin-list-container" id="mec_skin_1210">
<div class="mec-skin-list-events-container" id="mec_skin_events_1210">
No event found! </div>
</div>
or this if at least event is found
<div class="mec-wrap mec-skin-list-container" id="mec_skin_1210">
<div class="mec-skin-list-events-container" id="mec_skin_events_1210">
<div class="mec-wrap colorskin-custom">
<div class="mec-event-list-minimal">
<article data-style="" class="mec-event-article mec-clear mec-divider-toggle mec-toggle-202003-1210" itemscope="">
ARTICLE HERE
</article>
</div>
</div>
<div class="mec-skin-list-no-events-container" id="mec_skin_events_1210">
Nessun evento trovato! </div>
</div>
I need to hidden the first situation, I don't see the "No events found"
I have found a solution with css.
This work fine, but if I use display instead visibility, the code not work.
Work fine the "display:none" but I can't make it reappear the structure if event is found.
I have tried every value for "display" (block, flex, etc. etc.) nobody works
https://codepen.io/MarcoRM69/pen/VwLrXWb
.mec-skin-list-events-container {
visibility:hidden;
}
.mec-skin-list-events-container > div {
visibility:visible;
}
Any suggestions?
Modern browsers doesn't yet have impletemted has() pseudo-class unfortunately.
You can that easily with a JavaScript or library such as jQuery instead of using CSS. jQuery implement :has() selector.
Description: Selects elements which contain at least one element that matches the specified selector.
The expression $( "div:has(p)" ) matches a <div> if a <p> exists anywhere among its descendants, not just as a direct child.
$('.mec-skin-list-events-container').addClass("d-none");
$('.mec-skin-list-events-container:has(div)').addClass("d-block");
body {
color: green;
font-size: 1.25em;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.mec-skin-list-events-container+div:not(:has(div)) {
color: black;
}
.d-none {
display: none;
}
.d-block {
display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="mec-wrap mec-skin-list-container" id="mec_skin_1210">
<div class="mec-skin-list-events-container" id="mec_skin_events_1210">
Nessun evento trovato! </div>
</div>
<hr>
<div class="mec-wrap mec-skin-list-container" id="mec_skin_1210">
<div class="mec-skin-list-events-container" id="mec_skin_events_1210">
<div class="mec-wrap colorskin-custom">
<div class="mec-event-list-minimal">
<article data-style="" class="mec-event-article mec-clear mec-divider-toggle mec-toggle-202003-1210" itemscope="">
ARTICLE HERE
</article>
</div>
</div>
<div class="mec-skin-list-no-events-container" id="mec_skin_events_1210">
Nessun evento trovato! </div>
</div>
</div>
display: none... is not working, while visibility:hidden... is working because display: none removes the affected element from the page while visibility:hidden does not.
Since display:none removes the containing div, you cannot then ask to display the contained div.
From your codepen:
.mec-skin-list-events-container {
visibility:hidden;
/*display:none;*/
}
.mec-skin-list-events-container > div {
visibility:visible;
/*display:block;*/
}
I've got a menu with 3 levels of deepness. It starts with the categories, then the subcategories, and after all, the final links. Some of these links are already in the second or even the first level, but that's not a problem. The menu is working fine.
The problem is that I'm trying to make it look fancy, so I added to each div a class that designates the menu level. You can see the full Angular template here. Mind that these classes are the "lvl0", "lvl1", "lvl2":
<div class="menu-container">
<div class="row header">
<img class="logo" src="../../../assets/menu-header.PNG">
</div>
<div class="row menu-btn">
<div class="inner-menu-btn" (click)="openMenu()">
<span class="menu-span" [#menuStringAnim]="active">MENU</span>
<i class="fa fa-bars menu-icon" [#menuIconAnim]="active"></i>
</div>
</div>
</div>
<div class="menu-list" [#menuListAnim]="active">
<div class="row row-fix lvl0" *ngFor="let category of getCategories()" (click)="openCategory(category)">
<div class="little-menu-bar-toplvl" *ngIf="categoriesNavigator.lvl0 == category.key"></div>
<span class="menu-top-level">{{ category?.title?.toUpperCase() }} </span>
<div *ngIf="categoriesNavigator.lvl0 == category.key">
<br>
<div class="row row-fix lvl1" *ngFor="let subcategory of getSubcategories(category.key)" (click)="openSubcategory(subcategory)">
<div class="little-menu-bar-midlvl"></div>
<span class="menu-second-level">{{ subcategory?.title?.toUpperCase() }} </span>
<div *ngIf="categoriesNavigator.lvl1 == subcategory.key">
<br>
<div class="row row-fix lvl2" *ngFor="let thirdLevel of getThirdLevel(category.key, subcategory.key)" (click)="openUrl(thirdLevel)">
<div class="little-menu-bar-lowlvl" *ngIf="categoriesNavigator.lvl0 == category.key"></div>
<span class="menu-third-level">{{ thirdLevel?.title?.toUpperCase() }} </span>
</div>
</div>
</div>
</div>
</div>
</div>
So these classes are very simple. I'm not very good at CSS (I prefer designing logic rather than designing), and maybe I'm doing some stupid thing here:
.lvl0 :hover{
color: orange;
}
.lvl1 :hover{
color: orange;
}
.lvl2 :hover{
color: orange;
clear: both;
}
So the behavior works nice for first level, but as you can see, all the rows with the second level get highlighted instead of just the one I'm hovering on:
Same happens with the third level.
Do you have any idea on what I'm doing wrong? I'm adding the Angular tag just in case it has something to do with my template code. Thank you!
The problem is that you have applied the style to your div and as the divs are nested, the styles will cascade and turn everything inside it the colour - you can try to apply the styles directly to the spans to avoid this. Also I have removed the space before your hover colon
.lvl0:hover>span { /* leave hover on div but style the span */
color: orange;
}
.lvl1:hover>span {
color: red;
}
.lvl2:hover>span {
color: green;
}
<div class="lvl0">
<span>test 0</span>
<div class="lvl1">
<span>test 1</span>
<div class="lvl2">
<span>test 2</span>
</div>
</div>
</div>
The :hover is basically propagating down to other levels. Do not use CSS on the parent directly. Instead, use it on something like span etc.
Check pen here to solve your issue. In your case, you can have <div> tag too instead of the span which closes there and is basically a sibling of next level.
.lvl:hover {
//common for all
color: orange;
}
There are 2 text on page "ok" and "oops" one is under <footer> another under class=> 'meta'.
I want to verify footer text and I am using
span(:alert){div_element(:class => 'application').div_element(:class => 'txt').span_element(:class => 'app-text')}
but its verifying with meta "class" text "oops" as both have same div path.
How I can locate the span class "app-txt" inside footer specific?
<footer>
<div class="application" style="opacity: 1;">
<div class="txt" style="background-color: transparent;">
<span class="app-txt" style="background-color: transparent;">ok</span>
</div>
</div>
</footer>
<div class="meta">
<div class="application" style="opacity: 1;">
<div class="txt" style="background-color: transparent;">
<span class="app-txt" style="background-color: transparent;">oops</span>
</div>
</div>
</div>
To locate the ok use:
footer .app-txt
To locate the oops use:
.meta .app-txt
footer .app-txt {color: red;}
.meta .app-txt {color: orange;}
<footer>
<div class="application" style="opacity: 1;">
<div class="txt" style="background-color: transparent;">
<span class="app-txt" style="background-color: transparent;">ok</span>
</div>
</div>
</footer>
<div class="meta">
<div class="application" style="opacity: 1;">
<div class="txt" style="background-color: transparent;">
<span class="app-txt" style="background-color: transparent;">oops</span>
</div>
</div>
</div>
Given that you know that the two spans can be differentiated based on their ancestor element, ie the <footer> vs the <div class="meta">, you should include that in your locator.
Solution 1 - Using Nested Locators
The page object could be:
class MyPage
include PageObject
# The span in the footer
span(:in_footer) { footer_element.span_element(class: 'app-txt') }
# The span in the meta div
span(:in_meta) { div_element(class: 'meta').span_element(class: 'app-txt') }
end
As you can see, by including the differentiating ancestor element, ie the footer_element vs the div_element(class: 'meta'), you can get both texts:
p page.in_footer
#=> "ok"
p page.in_meta
#=> "oops"
Solution 2 - Using CSS-Selectors
Alternatively, depending on your comfort with CSS-selectors (or XPath), you could shorten the page object by using the CSS-selectors mentioned by #K.RajaSekharReddy or #PraveenKumar.
Using the CSS-selectors, the page object could be:
class MyPage
include PageObject
span(:in_footer, :css => 'footer .app-txt')
span(:in_meta, :css => '.meta .app-txt')
end
To locate the ok use:
footer >.application >.txt >span.app-txt {
color: blue;
}
or
footer >span.app-txt {
color: blue;
}
To locate the oops use:
.meta >.application >.txt >span.app-txt {
color: orange;
}
or
.meta >span.app-txt {
color: orange;
}