0
First of all, it is quite possible that there are already topics talking about this. It was not lack of research, I believe only that I did not find the correct keywords.
Self-explanatory question. I need a certain code to appear on the page, according to the class that was assigned to <div>
.
As an example, it would look something like this:
.a{
<img src="caminho/imagem1.png" title="Imagem 1" >
}
.b{
<img src="caminho/imagem2.png" title="Imagem 2" >
}
<div class="a"></div>
<p>
<div class="b"></div>
It is possible?
Why don’t you do this with jquery?
– adventistaam
My friend, as far as I know this is not possible... usually to load images in CSS you will have to do as in this example here:
background:#fafafa url('img/grey.png') repeat;
in this example to upload an image to the background of a div!– WPfan
Got confused your code and the question... You want if the class is ".to" a tag appears
<img>
within the<div>
kind of:<div class="a"><img src="caminho/imagem1.png" title="Imagem 1" ></div>
or you just want just that whenever you put the class ".to" to<div>
keep a background image?– hugocsl
@hugocsl , was just an example. I want the class to insert an HMTL into the code.
– ARodrigues
@wpfan, but in this example I cannot assign Tittle
– ARodrigues
is not possible, because the
css
does not foresee it, but you can do so, leave the image without the attributesrc
, and with a "hack" oncss
with a dial:.a img { content:url('caminho/imagem1.png'); }
– Ricardo Pontual
This class business assigning something to the body is usually created by a javascript or API that does it in real time in a dynamic way, as well as systems and will mask to
input
by attribute CLASS– RpgBoss
css is style language, i.e., it stylizes an existing document (or pseudo-elements) and not programming, so there is no point in doing such an operation in CSS, it would be more logical to use
display:none
the elements and add them in the HTML body and according to the class orhover
for example, they would be displayed.– Guilherme Nascimento
I know it’s an old question, but it’s worth reading this from here.
– Victor Stafusa