0
Good morning.
Today I came across a problem I’m not sure how to solve.
A promotion system generates some classes for some elements on my page, the problem is the way it generates, it puts traces/hyphens in the class name and it seems that it is impossible to manipulate.
It’s a promotional system, where my marketing team creates the promotions. The names of the promotions were created for example, with a name similar to that: "5 shirts for 99".
When the system generates the flags in the products that are part of this promotion, it creates an element p with class 5-shirts-by-99, being like this:
<p class="5-camisas-por-99">5 camisas por 99</p>
The problem is that I need to style this by taking the class, but the css doesn’t seem to manipulate classes that have strokes.
.5-camisas-por-99 {
padding: 10px;
background-color: black;
color: #FFF;
border-radius: 5px;
}
<p class="5-camisas-por-99">5 camisas por 99</p>
I also tried to do so, with the selector = but no results:
p[class^="camisas"] {
background-color: black;
padding: 10px;
border-radius: 5px;
color: #FFF;
}
<p class="5-camisas-por-99">5 camisas por 99</p>
Someone would have some solution to manipulate it?
OBS:
I don’t own the backend, I can’t change the system.
The promotions created need to be with the names like this, the marketing team decided this, I can not change. I really need to manipulate this class.
Thanks again, Hugo! The = It would be like a regular expression? I’ll give a read on the article you gave me.
– Lucas de Carvalho
@Lucasdecarvalho de boa my dear. In fact I don’t know much of regex to tell you for sure it works the same. but the syntax seems yes, in the link I left there in the answer there are some more technical things that may interest you. You have several
operator
you can use there, like*
,^
,~
,|
and$
each operator of this "selects" the strigs of the class name in a different way, I can’t tell you if this is the same in regex– hugocsl