Home Web Front-end HTML Tutorial How to achieve the slash header effect in a table

How to achieve the slash header effect in a table

Jan 17, 2018 am 09:33 AM
table sheet

This time I will show you how to realize the slash header effect in the table table. What are the things to note ? The following is a practical case, let’s take a look together. take a look.

Table, this thing must be familiar to everyone. We often encounter it in the code, so it is sometimes necessary to add a slash header to the table, but how to implement this What's the effect?

I have summarized the following methods:

1. The simplest and easiest way

Go directly to the company’s UI and ask her to make a picture as a background Just put the picture here and fill it up. Is not it simple! ! !

2. Quite a simple method

In fact, friends who know CSS3, when they see this effect, the attribute transform instantly appears in their mind. Yes, this is indeed possible, and it is very simple. , there is a problem that needs to be paid attention to the compatibility of browsers. Everyone must always maintain a sense of crisis (IE still exists). If your company's requirement is to only be compatible with chrome, then this method is suitable for you.

3. Very simple method

.biaoTou {
                border-top: 200px #199fff solid; /*上边框宽度等于表格第一行行高*/ 
                border-left: 200px #ff8838 solid; /*左边框宽度等于表格第一行第一格宽度*/ 
            }
 
<td width="200">
    <div class="biaoTou">
                         
    </div>
</td>
Copy after login

This method is also very simple, just write it down according to the above format. However, there is an obvious problem with this way of writing: This method actually uses two different colors of borders to divide the diagonal line of the table header. The colors on both sides of the diagonal line cannot be the same. If you are doing some forms such as promotional activities, you can Use this method. But if we need the colors on both sides of the slash to be the same, this approach is not applicable. Use with caution.

4. Very simple method

This effect can actually be achieved by using canvas, another new tag of CSS3. Using it as a canvas to draw a diagonal line is a very simple method, so I won’t explain it in detail. However, there is also a problem, which is the common compatibility issue. If it is only compatible with chrome, you can do whatever you want (why our company I always have to consider the abominable IE, and I also want to only do projects that are compatible with Google).

5. Not a simple method

That is the js method

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<HTML> 
<HEAD> 
<TITLE>斜线表头</TITLE> 
<meta http-equiv="content-type" content="charset=gbk"> 
</HEAD> 
   
<body leftmargin=0 topmargin=0> 
    <br> 
    <div height="300">header</div> 
    <hr> 
    <TABLE border=0 bgcolor="000000" cellspacing="1" width=400 
        style="margin-left: 100px;"> 
        <TR bgcolor="FFFFFF"> 
            <TD width="111" height="52"><table width="100%" height="100%" 
                    border="0" cellpadding="0" cellspacing="0"> 
                    <tr> 
                        <td id="td1"></td> 
                        <td>成绩</td> 
                    </tr> 
                    <tr> 
                        <td>姓名</td> 
                        <td id="td2"></td> 
                    </tr> 
                </table></TD> 
            <TD width="81">数学</TD> 
            <TD width="96">英语</TD> 
            <TD width="99">C语言</TD> 
        </TR> 
        <TR bgcolor="FFFFFF"> 
            <TD>张三</TD> 
            <TD>55</TD> 
            <TD>66</TD> 
            <TD>77</TD> 
        </TR> 
        <TR bgcolor="FFFFFF"> 
            <TD>李四</TD> 
            <TD>99</TD> 
            <TD>68</TD> 
            <TD>71</TD> 
        </TR> 
        <TR bgcolor="FFFFFF"> 
            <TD>王五</TD> 
            <TD>33</TD> 
            <TD>44</TD> 
            <TD>55</TD> 
        </TR> 
    </TABLE> 
    <script type="text/javascript"> 
        function a(x, y, color) { 
            document 
                    .write("<img   border=&#39;0&#39;   style=&#39;position:   absolute;   left:   " 
                            + (x) 
                            + ";   top:   " 
                            + (y) 
                            + ";background-color:   " 
                            + color 
                            + "&#39;   src=&#39;px.gif&#39;   width=1   height=1>") 
        } 
        function getTop(tdobj) { 
            vParent = tdobj.offsetParent; 
            t = tdobj.offsetTop; 
            while (vParent.tagName.toUpperCase() != "BODY") { 
                t += vParent.offsetTop; 
                vParentvParent = vParent.offsetParent; 
            } 
            return t; 
        } 
   
        function getLeft(tdobj) { 
            vParent = tdobj.offsetParent; 
            t = tdobj.offsetLeft; 
            while (vParent.tagName.toUpperCase() != "BODY") { 
                t += vParent.offsetLeft; 
                vParentvParent = vParent.offsetParent; 
            } 
            return t; 
        } 
        function line(x1, y1, x2, y2, color) { 
            var tmp 
            if (x1 >= x2) { 
                tmp = x1; 
                x1 = x2; 
                x2 = tmp; 
                tmp = y1; 
                y1 = y2; 
                y2 = tmp; 
            } 
            for ( var i = x1; i <= x2; i++) { 
                x = i; 
                y = (y2 - y1) / (x2 - x1) * (x - x1) + y1; 
                a(x, y, color); 
            } 
        } 
        //line(1,1,100,100,"000000");  
        line(getLeft(td1), getTop(td1), getLeft(td1) + td1.offsetWidth, 
                getTop(td1) + td1.offsetHeight, &#39;#000000&#39;); 
        line(getLeft(td2), getTop(td2), getLeft(td2) + td2.offsetWidth, 
                getTop(td2) + td2.offsetHeight, &#39;#000000&#39;); 
    </script> 
</BODY> 
</HTML>
Copy after login

I believe you have mastered the method after reading these cases. For more exciting things, please pay attention to other php Chinese websites related articles!

Related reading:

How to insert a video into an HTML webpage

How to use HTML+CSS to make a mouseover You can display the secondary menu bar

How to make the front-end interface automatically clear the cache of js and css files

The above is the detailed content of How to achieve the slash header effect in a table. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Steps to adjust the format of pictures inserted in PPT tables Steps to adjust the format of pictures inserted in PPT tables Mar 26, 2024 pm 04:16 PM

1. Create a new PPT file and name it [PPT Tips] as an example. 2. Double-click [PPT Tips] to open the PPT file. 3. Insert a table with two rows and two columns as an example. 4. Double-click on the border of the table, and the [Design] option will appear on the upper toolbar. 5. Click the [Shading] option and click [Picture]. 6. Click [Picture] to pop up the fill options dialog box with the picture as the background. 7. Find the tray you want to insert in the directory and click OK to insert the picture. 8. Right-click on the table box to bring up the settings dialog box. 9. Click [Format Cells] and check [Tile images as shading]. 10. Set [Center], [Mirror] and other functions you need, and click OK. Note: The default is for pictures to be filled in the table

How to make a table for sales forecast How to make a table for sales forecast Mar 20, 2024 pm 03:06 PM

Being able to skillfully make forms is not only a necessary skill for accounting, human resources, and finance. For many sales staff, learning to make forms is also very important. Because the data related to sales is very large and complex, and it cannot be simply recorded in a document to explain the problem. In order to enable more sales staff to be proficient in using Excel to make tables, the editor will introduce the table making issues about sales forecasting. Friends in need should not miss it! 1. Open [Sales Forecast and Target Setting], xlsm, to analyze the data stored in each table. 2. Create a new [Blank Worksheet], select [Cell], and enter [Label Information]. [Drag] downward and [Fill] the month. Enter [Other] data and click [

How to set WPS value to automatically change color according to conditions_Steps to set WPS table value to automatically change color according to condition How to set WPS value to automatically change color according to conditions_Steps to set WPS table value to automatically change color according to condition Mar 27, 2024 pm 07:30 PM

1. Open the worksheet and find the [Start]-[Conditional Formatting] button. 2. Click Column Selection and select the column to which conditional formatting will be added. 3. Click the [Conditional Formatting] button to bring up the option menu. 4. Select [Highlight conditional rules]-[Between]. 5. Fill in the rules: 20, 24, dark green text with dark fill color. 6. After confirmation, the data in the selected column will be colored with corresponding numbers, text, and cell boxes according to the settings. 7. Conditional rules without conflicts can be added repeatedly, but for conflicting rules WPS will replace the previously established conditional rules with the last added rule. 8. Repeatedly add the cell columns after [Between] rules 20-24 and [Less than] 20. 9. If you need to change the rules, you can just clear the rules and then reset the rules.

How to use JavaScript to implement drag-and-drop adjustment of table column width? How to use JavaScript to implement drag-and-drop adjustment of table column width? Oct 21, 2023 am 08:14 AM

How to use JavaScript to realize the drag-and-drop adjustment function of table column width? With the development of Web technology, more and more data are displayed on web pages in the form of tables. However, sometimes the column width of the table cannot meet our needs, and the content may overflow or the width may be insufficient. In order to solve this problem, we can use JavaScript to implement the drag-and-drop adjustment function of the column width of the table, so that users can freely adjust the column width according to their needs. To realize the drag-and-drop adjustment function of table column width, the following three main points are required:

What should I do if the form cannot be printed outside the dotted line? What should I do if the form cannot be printed outside the dotted line? Mar 28, 2023 am 11:38 AM

Solution to the problem that the table cannot be printed outside the dotted line: 1. Open the excel file and click "Print" on the opened page; 2. Find "No Zoom" on the preview page and select to adjust to one page; 3. Select the printer to print. Documentation is enough.

How to remove duplicate borders of table in css How to remove duplicate borders of table in css Sep 29, 2021 pm 06:05 PM

In CSS, you can use the border-collapse attribute to remove duplicate borders in the table. This attribute can set whether the table border is collapsed into a single border or separated. You only need to set the value to collapse to merge overlapping borders together. Become a border to achieve the effect of a single line border.

How to export and import table data in Vue How to export and import table data in Vue Oct 15, 2023 am 08:30 AM

How to implement the export and import of tabular data in Vue requires specific code examples. In web projects developed using Vue, we often encounter the need to export tabular data to Excel or import Excel files. This article will introduce how to use Vue to implement the export and import functions of table data, and provide specific code examples. 1. Installation dependencies for exporting table data First, we need to install some dependencies for exporting Excel files. Run the following command from the command line in your Vue project: npmin

Do you know how to sum a Word table? Do you know how to sum a Word table? Mar 21, 2024 pm 01:10 PM

Sometimes, we often encounter counting problems in Word tables. Generally, when encountering such problems, most students will copy the Word table to Excel for calculation; some students will silently pick up the calculator. Calculate. Is there a quick way to calculate it? Of course there is, in fact the sum can also be calculated in Word. So, do you know how to do it? Today, let’s take a look together! Without further ado, friends in need should quickly collect it! Step details: 1. First, we open the Word software on the computer and open the document that needs to be processed. (As shown in the picture) 2. Next, we position the cursor on the cell where the summed value is located (as shown in the picture); then, we click [Menu Bar

See all articles