Si vous lisez les publications de publicités internes, elles vous indiquent comment définir une image pour le bureau et une autre pour mobile.
<a href="" class="banner-ad" target="_blank">
<img class="desktop" src="">
<img class="mobile" src="">
</a>
Il suffit de définir les images pour chaque format (moins large pour les téléphones et plus large pour le bureau), et c’est tout !
Personnellement, j’utilise ces dimensions :
- Mobile : 1282x311
- Bureau : 755x90
Ensuite, créez un composant et ajoutez ce CSS :
$cta-background-color: #FE4644;
$cta-text-color: #FFFFFF;
.banner-ad {
display: flex;
clear: both;
max-width: calc(#{$topic-body-width} + #{$topic-avatar-width} + (#{$topic-body-width-padding} * 2));
background-color: #FEF25E;
border: 1px solid $primary;
box-sizing: border-box;
img {
height: 90px;
&.desktop {
display: block;
}
&.mobile {
display: none;
width: 100%;
}
}
.container {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
p {
margin: 0;
&.small {
font-weight: bold;
text-align: right;
padding: 1px 5px;
background-color: #000000;
color: #FFFFFF;
}
&.big {
font-size: 24px;
line-height: normal;
padding-bottom: 5px;
color: #434343;
font-weight: lighter;
}
}
.cta {
color: $cta-text-color;
background-color: $cta-background-color;
&:hover {
background-color: darken($cta-background-color, 20%);
}
}
}
}
@media only screen and (max-width: 672px) {
.banner-ad {
img.desktop, p {
display: none;
}
img.mobile {
display: block;
}
.container {
justify-content: center;
.cta {
margin: 0 5px;
font-size: 12px;
}
}
}
}
Des dimensions étranges, mais ça fonctionne ! Vous pouvez voir cela en action ici.
Cela ne vaut pas la peine de payer pour cela… Peut-être qu’il est préférable de faire un don à Discourse !