Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HTML/CSS Sprechblase

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe mir für meine Website eine Sprechblase von Demo: Pure CSS speech bubbles – Nicolas Gallagher ausgesucht:

sprechblase.png

Nur leider scheitere ich etwas am Anpassen...

Ich habe den Rahmen des <div> von 5px auf 3px verringert.

Der Rahmen des Pfeils bleibt allerdings so dick. Ich will ihn aber auch 3px dick haben. Ich habe rausgefunden, dass er aus zwei übereinanderliegenden Dreiecken besteht.

Das untere, randfarbene Dreieck ist größer als das obere. Das obere, kleinere Dreieck ist weiß. Durch die Übelappung wird der Pfeileffekt erzeugt und man denkt, es wäre ein Rand darum.

Ich muss also entweder das untere Dreieck um 2px kleiner machen oder das obere um 2px größer. Nur habe ich echt keine Ahnung, wie das gehen soll. Die Dreiecke verrutschen und verzerren, egal was ich mache.

Bei der Sprechblase werden die Pseudoklassen :after und :before verwendet! Außerdem die CSS-Eigenschaft content. Kennt sich jemand damit aus?


.triangle-border { 	position:relative; 	padding:15px; 	margin:1em 0 3em; 	border:5px solid #5a8f00; 	color:#333; 	background:#fff; 	/* css3 */ 	-webkit-border-radius:10px; 	-moz-border-radius:10px; 	border-radius:10px; }


.triangle-border.right { 	margin-right:30px; }



.triangle-border:before { 	content:""; 	position:absolute; 	bottom:-20px; /* value = - border-top-width - border-bottom-width */ 	left:40px; /* controls horizontal position */     border-width:20px 20px 0; 	border-style:solid;     border-color:#5a8f00 transparent;     /* reduce the damage in FF3.0 */     display:block;      width:0; }  /* creates the smaller  triangle */ .triangle-border:after { 	content:""; 	position:absolute; 	bottom:-13px; /* value = - border-top-width - border-bottom-width */ 	left:47px; /* value = (:before left) + (:before border-left) - (:after border-left) */ 	border-width:13px 13px 0; 	border-style:solid; 	border-color:#fff transparent;     /* reduce the damage in FF3.0 */     display:block;      width:0; }


/* creates the larger triangle */ .triangle-border.right:before { 	top:10px; /* controls vertical position */ 	bottom:auto;     left:auto; 	right:-30px; /* value = - border-left-width - border-right-width */ 	border-width:15px 0 15px 30px; 	border-color:transparent #5a8f00; }  /* creates the smaller  triangle */ .triangle-border.right:after { 	top:16px; /* value = (:before top) + (:before border-top) - (:after border-top) */ 	bottom:auto;     left:auto; 	right:-21px; /* value = - border-left-width - border-right-width */ 	border-width:9px 0 9px 21px; 	border-color:transparent #fff; }



Vielen Dank schonmal!

LG Luk

Hier noch mein Problem als Bild:

meine%20sprechblase.png

  • Autor

Hey, danke für eure Antworten. Leider gab es die Eigenschaft triangle-border nicht^^

Ich habe es jetzt mit ausprobieren endlich hinbekommen!

Was das aber für eine seltsame Pseudo-Klasse ist, das habe ich immer noch nich verstanden xD

LG Luk

.triangle-border { position:relative; padding:15px; margin:1em 0 3em; border:5px solid #5a8f00; color:#333; background:#fff; /* css3 */ -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; }

Steht doch dort.

  • Autor

Sicher doch! Allerdings habe ich einige Klassen zusammengefasst. Sieht etwas anders aus, als das Original, macht aber das gleiche! Habe es mit Hilfe der Kommentare zur Berechnungder Werte hinbekommen.


/* Sprechblase - http://nicolasgallagher.com/pure-css-speech-bubbles/demo/ */


.triangle-border

{

	position: absolute;

	right: 240px;

	top: 300px;

	padding: 10px;

	border: 3px solid #000000;

	color: #000000;

	background: #FFFFFF;

	-webkit-border-radius: 10px;

	-moz-border-radius: 10px;

	border-radius: 10px;

	max-width: 150px;

}


/* creates the larger triangle */

.triangle-border.right:before

{

	content: "";

	position: absolute;

	border-style : solid;

        /* reduce the damage in FF3.0 */

        display: block; 

        width: 0;


	top: 10px; /* controls vertical position */

	bottom: auto;

        left: auto;

	right: -30px; /* value = - border-left-width - border-right-width */

	border-width: 15px 0 15px 30px;

	border-color: transparent #000000;

}


/* creates the smaller  triangle */

.triangle-border.right:after

{

	content: "";

	position: absolute;

	border-style: solid;

        /* reduce the damage in FF3.0 */

        display: block; 

        width: 0;


	top: 13px; /* value = (:before top) + (:before border-top) - (:after border-top) */

	bottom: auto;

        left: auto;

	right: -24px; /* value = - border-left-width - border-right-width */

	border-width: 12px 0 12px 24px;

	border-color: transparent #FFFFFF;

}


Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.