Click here to Skip to main content
15,936,460 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a div tag,
| |
| |
| |

I want to add a small triangle over it.Like...

| |
| |
| |

This can be achieved through a little bit of css here.

The div will be there and we have to put an another div with its background set as the similar image which will create an illusion of the triange connected to the div itself. Again the triangle image will hide the existing border of the div at the point and display it like the triangle is connected to div.

The triangle image position should be set to a -ve value to go out of the
to a desired position.

Ex :-

First the css for the triangle should be look like below :-
You can edit it as per your need, it is written for adding atop triangle to main

.arrow-up {
    width: 31px;
    height: 23px;
    position: absolute;
    top: -23px;
    left: 22px;
    background: url('write triangle image url here') 0 0 no-repeat;

Now here is the demo html for main and the inner div which can use this to display like triangle added at the top of main division :-

<div class="popup" style="top: 821px; left: 159.5px; display: block;">

    <div class="arrow-up"></div>
            <img src="some image url here" height="40" width="100" alt="Font Preview">

            <a class="demoClass1" href="#">Demo</a>
            <b>all products $29.00</b>
        <a class="demoClass2" href="#">More</a>

The triangle image border design and the main div border design should match to make them look like single element only.

Please remember that this just for giving you the hint how this can be achieved and no guarantee that it will work as it is , just you need to modify it as per your need.

Hope this will be definitely show a light on your path.
Share this answer
try this.. :)

position: relative;
width: 250px;
height: 120px;
padding: 0px;
background: #000000;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;

content: "";
position: absolute;
top: -33px;
left: 182px;
border-style: solid;
border-width: 0 15px 33px;
border-color: #000000 transparent;
display: block;
width: 0;
z-index: 1;

<div class="bubble "></div>

try your self.. :)

CSS speech bubble generator[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900