Comment rendre ces patériares être réactivant par l'élément parent?
p>
<svg style="width: 100px; height: 100px;" id="square"> <g> <rect height="50" width="50" y="0" x="0" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect height="50" width="50" y="50" x="50" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect height="50" width="50" y="0" x="50" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect height="50" width="50" y="50" x="0" stroke-width="2" stroke="gray" fill="#B0b0b0"/> </g> </svg>
3 Réponses :
Vous pouvez obtenir la même chose à l'aide de CSS et d'arrière-plan, il sera facile de modifier la taille:
p>
<svg style="width: 100px; height: 100px;" id="square"> <g> <rect y="0" x="0" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect y="50%" x="50%" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect y="0" x="50%" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect y="50%" x="0" stroke-width="2" stroke="gray" fill="#B0b0b0"/> </g> </svg> <svg style="width: 200px; height: 200px;" id="square"> <g> <rect y="0" x="0" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect y="50%" x="50%" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect y="0" x="50%" stroke-width="2" stroke="gray" fill="#B0b0b0"/> <rect y="50%" x="0" stroke-width="2" stroke="gray" fill="#B0b0b0"/> </g> </svg>
Ceci n'est pas réactif. Le code que vous avez fourni est défini.
Vous devez utiliser la VIEOWBOX sur SOUND SVG P> Ici la solution: p> "0 0 100 100" CODE>.
Si vous aimez créer un élément réactif, il y a une très bonne tour. Vous pouvez l'adapter à n'importe quel rapport que vous souhaitez avec p> Padding-top: 100%; code> Vous obtenez un rapport 1: 1.
<div class="ratio">
<div class="box"></div>
</div>
Vous voulez dire qu'ils peuvent être déformés en fonction de la largeur / de la hauteur?
Oui, je veux définir: