Click here to Skip to main content
13,192,207 members (35,165 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I have a div tag,
__________
| |
| |
| |
|__________|

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

_______/\_
| |
| |
| |
|__________|
Posted 9-Jun-14 18:50pm
MAGuru658
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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>
        <p>
            <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>
        </p>
        <a class="demoClass2" href="#">More</a>
</div>


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.
  Permalink  
v4
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

try this.. :)

.bubble 
{
position: relative;
width: 250px;
height: 120px;
padding: 0px;
background: #000000;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
 
.bubble:after 
{
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[^]
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171017.2 | Last Updated 10 Jun 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100