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 phải với JavaScript?

Sử dụng borderTopRightRadius để đặt bán kính bo góc viền trên bên phả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 phải</button>
    <script>
      function display() {
        document.getElementById("box").style.borderTopRightRadius = "20px";
      }
    </script>
  </body>
</html>