locked
Problem to align button RRS feed

  • Question

  • User364663285 posted

    Hi,
    I want to align button below in the middle. But it does not work as expected. What to adjust?

                    html += "<td><a href='#' class='btnDelete' style='text-align:center;' data-house-id='" + house.house_id + "'>删除记录</a></td>";
    

    Thursday, March 22, 2018 9:32 AM

Answers

  • User475983607 posted

    Your question is not clear.  I assume you want to center the button in the <td>?  

    html += "<td style='text-align:center;'><a href='#' class='btnDelete' data-house-id='" + house.house_id + "'>删除记录</a></td>";

    Use developer tools (F12) to debug your CSS as there is no guarantee the code above will work since we cannot see the rest of your HTML. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2018 11:04 AM

All replies

  • User475983607 posted

    Your question is not clear.  I assume you want to center the button in the <td>?  

    html += "<td style='text-align:center;'><a href='#' class='btnDelete' data-house-id='" + house.house_id + "'>删除记录</a></td>";

    Use developer tools (F12) to debug your CSS as there is no guarantee the code above will work since we cannot see the rest of your HTML. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2018 11:04 AM
  • User-1838255255 posted

    Hi wmec,

    According to your description, if you want to align tag a at the center of the td, please check the following sample code:

     <script>
            var house_id = "111";
            var line = "<table style='border:1px solid red;width:200px;'><tr><td style='text-align:center;'><a href='#' class='btnDelete' style='text-align:center;' data-house-id='" + house_id + "'>删除记录</a></td></tr></td>";
            document.write(line);
        </script>

    Result:

    Best Regards,

    Eric Du 

    Friday, March 23, 2018 8:28 AM