Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Cách đặt hình dạng góc viền trên bên trái với JavaScript?

Sử dụng borderTopLeftRadius để đặt bán kính bo góc viền trên bên trái.

Ví dụ

<!DOCTYPE html>
<html>
  <head>
    <style>
      #box { border: thick solid gray; width: 300px; height: 200px; }
    </style>
  </head>
  <body>
    <div id="box">Demo Text</div>
    <br><br>
    <button type="button" onclick="display()">Thay đổi góc trên trái</button>
    <script>
      function display() {
        document.getElementById("box").style.borderTopLeftRadius = "20px";
      }
    </script>
  </body>
</html>