Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6814161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:39:22+00:00 2026-05-26T20:39:22+00:00

How can I create a diagonal line from the lower left corner to the

  • 0

How can I create a diagonal line from the lower left corner to the upper right corner of any given cell?

To get this

<table>
    <tr>
        <td class="crossOut">A1</td>
        <td>B1</td>
    </tr>
    <tr>
        <td>A2 Wide</td>
        <td class="crossOut">B2<br/>Very<br/>Tall</td>
    </tr>
</table>

to show this

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:39:23+00:00Added an answer on May 26, 2026 at 8:39 pm

    I don’t know if is the best way, but I can’t do that with CSS. My answer is in jQuery:

    http://jsfiddle.net/zw3Ve/13/

    $(function(){
        $('.crossOut').each(function(i){
            var jTemp = $(this),
                nWidth = jTemp.innerWidth(),
                nHeight = jTemp.innerHeight(),
                sDomTemp = '<div style="position:absolute; border-color: transparent black white white; border-style:solid; border-width:'+nHeight +'px '+nWidth +'px 0px 0px; width:0; height:0; margin-top:-'+nHeight+'px; z-index:-2"></div>';
    
            sDomTemp += '<div style="position:absolute; border-color: transparent white white white; border-style:solid; border-width:'+nHeight +'px '+nWidth +'px 0px 0px; width:0; height:0; margin-top:-'+(nHeight-1)+'px; z-index:-1"></div>';
    
            jTemp.append(sDomTemp);
        });
    });
    

    or

    http://jsfiddle.net/zw3Ve/16/ (with CSS class cleaner)

    CSS part:

    .crossOut .child{
        position:absolute; 
        width:0; 
        height:0;
        border-style:solid;
    }
    .crossOut .black-triangle{
        z-index:-2;
        border-color: transparent black white white;
    }
    .crossOut .white-triangle{
        border-color: transparent white white white;
        z-index:-1;
    }
    

    jQuery code:

    $(function(){
        $('.crossOut').each(function(i){
            var jTemp = $(this),
                nWidth = jTemp.innerWidth(),
                nHeight = jTemp.innerHeight(),
                sDomTemp = '<div class="child black-triangle" style="border-width:'+nHeight +'px '+nWidth +'px 0px 0px; margin-top:-'+nHeight+'px; "></div>';
    
            sDomTemp += '<div class="child white-triangle" style="border-width:'+nHeight +'px '+nWidth +'px 0px 0px; margin-top:-'+(nHeight-1)+'px;"></div>';
    
            jTemp.append(sDomTemp);
        });
    });
    

    The good thing is it works with any width and height of a table cell.

    Edit:

    I was not happy with the quality of rendering of triangles made ​​with CSS borders so I used the css-rotation. I think this is a better work (and the lines are render better):

    http://jsfiddle.net/zw3Ve/21/

    (Using -sand-transform is for IE6, so it use is optional.)

    Edit2:
    The last version has not got support for IE7-IE8 (seems the -sand-transform only works in CSS styles and not in styles written by JavaScript). I made a version with compatibility with old browsers:

    http://jsfiddle.net/zw3Ve/23/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to create a diagonal line with jQuery that animates from top left
Currently i's look at this question ( How to create a diagonal line within
Can we create a HTTP request (GET or POST) programmatically. Like in other protocols(ex
This can create an array dynamically: Assembly asm = object.GetType().Assembly; string sTypeName = Company.Namespace.ClassName;
how can create ratings using UIPicker, eg. 0-star to 5-star, how this can be
I can create a page from a file with: Page page = BuildManager.CreateInstanceFromVirtualPath( virtualPath,
I can create a new object like this: Dim sqlconn As New SqlClient.SqlConnection(cs) or
I can create p as a pointer to f like this: f: func[][print 1]
How can I write in WPF diagonal line with drap and drop behavior? I
You can create a thread given a delegate to method, can I create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.