tags:

views:

63

answers:

2

Hi

Can some CSS expert help guide me to achieve slant line in a box via css. I can't attached the image. I know this can be done but lack of expert knowledge over css I am missing the way to achieve this. I am referring to this example. If you go end of the page (slanthowto.html) there is a image which show only slanted black line... I want to implement the same.

Regards,

+2  A: 

That's the CSS and HTML code for the slanted black line:

<div style="position: relative; width: 100px; height: 100px;">
  <div style="position: absolute; top: 0px; left: 0px; border-color: transparent transparent transparent rgb(64, 0, 0); border-width: 0px 0px 65px 87px;" class="borderdraw"><!-- --></div>
  <div style="position: absolute; top: 0px; left: 0px; border-color: transparent transparent transparent rgb(255, 240, 240); border-width: 0px 0px 64px 85px;" class="borderdraw"><!-- --></div>
</div>

The CSS:

.borderdraw {
    border-style:solid;
    height:0;
    line-height:0;
    width:0;
}

EDIT: You can also copy the properties from the class to the style attribute:

<div style="position: relative; width: 100px; height: 100px;">
  <div style="position: absolute; top: 0px; left: 0px; border-color: transparent transparent transparent rgb(64, 0, 0); border-width: 0px 0px 65px 87px; border-style: solid; height: 0; line-height: 0; width: 0;"><!-- --></div>
  <div style="position: absolute; top: 0px; left: 0px; border-color: transparent transparent transparent rgb(255, 240, 240); border-width: 0px 0px 64px 85px; border-style: solid; height: 0; line-height: 0; width: 0;"><!-- --></div>
</div>
Kau-Boy
This worked exactly ! Awesome
A: 

Don't use this method. No seriously, don't. Look at the date at the bottom of the page. It says

Last modified: Thu Jan 30 21:56:16 Romance Standard Time 2003

That's seven years ago. Technology's moved on. We don't do this anymore. Just go use any graphics manipulation software, draw yourself a triangle, and use either of these two techniques to stick a image into your webpage.

First of all, the image. Here's one I created in Paint earlier:

alt text

Then, with either the img tag

<img src="triangle.png" alt="Triangle!" />

or the background, with CSS method

<div class="triangle"></div>


.triangle {
    background: url('triangle.png') no-repeat;
    width: 120px;
    height: 120px;
}

That's better, isn't it.

Yi Jiang
Thanks Yi. Can you please help me to understand the basics .. Sorry for been so noob.I have 140 occurrence of such instance (box with slant line) on my page hence I thought it's good to have CSS based class rather then an image.Please help me to understand that which way is good to have CSS or the images in such scenarios.
@pritisolanki Don't apologies - that's what's this site for. The comment boxes aren't really the best place to ask (or answer) questions. If you've got something complicated, ask a new question on this site. For the difference between the two, see: http://dev.opera.com/articles/view/17-images-in-html/#imagetypes. The reason why it's good to use either of the above methods, is because that's how you're suppose to do it - borders are for borders, and nothing else really.
Yi Jiang