Bulle de discussion dégradée défilante
P粉197639753
P粉197639753 2023-09-01 11:52:18
0
2
626
<p>Je veux un conteneur blanc avec une bulle de discussion avec un dégradé qui change lors du défilement avec le dégradé ci-dessous, comme indiqué dans cet exemple : </p> <p>J'ai essayé de rendre la partie <code>.container</code> derrière tout <code>chatBubble</code> transparent afin que l'arrière-plan de <code>.root</code> </p> <p> <pre class="brush:css;toolbar:false;">.root { couleur d'arrière-plan : dégradé linéaire (rouge, jaune) ; largeur : 100vw ; hauteur : 100vh ; } .récipient { largeur : 100 % ; hauteur : 100vh ; couleur de fond : blanc } .chatBulle { couleur d'arrière-plan : transparent ; rayon de bordure : 4 px ; largeur minimale : 50 ; remplissage : 10 px ; }</pré> <pre class="brush:html;toolbar:false;"><div class="root"> <div class="conteneur"> <chatBubble>Ceci est une bulle de discussion</chatBubble> <chatBubble> Ceci est une autre bulle de discussion</chatBubble> </div> </div></pre> </p>
P粉197639753
P粉197639753

répondre à tous(2)
P粉293550575

C'est ce que j'ai fait jusqu'à présent, j'essaie de le masquer pour pouvoir avoir un fond blanc pour accompagner le dégradé.

html,
body,
.container {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui;
}

.container {
  display: flex;
  flex-flow: column nowrap;
  max-width: 60ch;
  margin: auto;
  padding: 1rem;
  background-color: white;
}

.container::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(red, yellow);
}

.bubble {
  z-index: 1;
  min-width: 50px;
  width: fit-content;
  background-color: #eee;
  border-radius: 4px;
  padding: 0.5em;
  margin: 0.2em;
  text-wrap: balance;
}

.bubble.primary {
  color: white;
  background-color: transparent;
  background-blend-mode: multiply;
  align-self: end;
  text-align: end;
}
<div class="container">
  <div class="bubble">show weekend?</div>
  <div class="bubble primary">I'm down!</div>
  <div class="bubble">lets do this its been way to long since we were all together!</div>
  <div class="bubble primary ">Whos down for a pregame</div>
  <div class="bubble">YES! I got the day off! Say when and where?</div>
  <div class="bubble primary">Hows about Old Town at 4? we can get some grub and then head over to the venue</div>
  <div class="bubble">Yeah getting the band back together</div>
  <div class="bubble">show weekend?</div>
  <div class="bubble primary">I'm down!</div>
  <div class="bubble">lets do this its been way to long since we were all together!</div>
  <div class="bubble primary ">Whos down for a pregame</div>
  <div class="bubble">YES! I got the day off! Say when and where?</div>
  <div class="bubble primary">Hows about Old Town at 4? we can get some grub and then head over to the venue</div>
  <div class="bubble">Yeah getting the band back together</div>
  <div class="bubble">show weekend?</div>
  <div class="bubble primary">I'm down!</div>
  <div class="bubble">lets do this its been way to long since we were all together!</div>
  <div class="bubble primary ">Whos down for a pregame</div>
  <div class="bubble">YES! I got the day off! Say when and where?</div>
  <div class="bubble primary">Hows about Old Town at 4? we can get some grub and then head over to the venue</div>
  <div class="bubble">Yeah getting the band back together</div>
</div>
P粉277824378

Vous pouvez « Placer l'ombre » à partir de .bubble : 

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  --gap: 20px;
  --width: 800px;
  --background: #fff;
  display: flex;
  flex-direction: column;
  max-width: var(--width);
  margin: 16px auto;
  padding: 0 16px;
  overflow: hidden;
  gap: var(--gap);
  box-shadow: 0 0 0 100vw var(--background);
  font-family: sans-serif;
}

.container:before {
  content: '';
  inset: 0;
  position: fixed;
  z-index: -1;
  background: linear-gradient(purple, blue);
}

.bubble {
  max-width: 80%;
  background-color: lightgray;
  border-radius: 16px;
  padding: 8px 16px;
  box-shadow: 0 0 0 var(--gap) var(--background);
  position: relative;
}

.bubble::before,
.bubble::after {
  content: '';
  position: absolute;
  inset: calc(var(--gap) / -2) auto;
  background-color: var(--background);
  width: var(--width);
}

.bubble::before {
  right: 100%;
}

.bubble::after {
  left: 100%;
}

.bubble.primary {
  background-color: transparent;
  color: #fff;
  align-self: flex-end;
}
<div class="container">
  <div class="bubble">show weekend?</div>
  <div class="bubble primary">I'm down!</div>
  <div class="bubble">lets do this its been way to long since we were all together!</div>
  <div class="bubble primary ">Whos down for a pregame</div>
  <div class="bubble">YES! I got the day off! Say when and where?</div>
  <div class="bubble primary">Hows about Old Town at 4? we can get some grub and then head over to the venue</div>
  <div class="bubble">Yeah getting the band back together</div>
  <div class="bubble">show weekend?</div>
  <div class="bubble primary">I'm down!</div>
  <div class="bubble">lets do this its been way to long since we were all together!</div>
  <div class="bubble primary ">Whos down for a pregame</div>
  <div class="bubble">YES! I got the day off! Say when and where?</div>
  <div class="bubble primary">Hows about Old Town at 4? we can get some grub and then head over to the venue</div>
  <div class="bubble">Yeah getting the band back together</div>
  <div class="bubble">show weekend?</div>
  <div class="bubble primary">I'm down!</div>
  <div class="bubble">lets do this its been way to long since we were all together!</div>
  <div class="bubble primary ">Whos down for a pregame</div>
  <div class="bubble">YES! I got the day off! Say when and where?</div>
  <div class="bubble primary">Hows about Old Town at 4? we can get some grub and then head over to the venue</div>
  <div class="bubble">Yeah getting the band back together</div>
</div>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!