HTMLについて質問です。
バージョンはHTML5を使用しています。
cssでwidthを%で指定しているのですが、下記のような違いがあります。
・div
⇒小数点まで計算される
・table要素のthやtd
⇒小数点が切り捨てられる
この差異をなくすためにはcssやHTMLでどのような記述の方法がありますでしょうか?
ブラウザはGoogle Chromeです。
<!DOCTYPE html> <html> <head> <title>台帳レイアウト 作成中</title> <meta charset="UTF-8"> <style> section { padding-bottom: 20px; } .width-33 { width: 33%; } .width-77 { width: 67%; } table { display: table; border-collapse: collapse; border-spacing: 0; border-color: #A9A9A9; margin-top: 0; margin-bottom: 0; width: 100%; } th { border: 1px solid black; } .div-parent { display: flex; } .div-parent>div:nth-of-type(1) { border: 1px solid black; border-right: none; } .div-parent>div:nth-of-type(2) { border: 1px solid black; } </style> </head> <body> <section> <table> <thead> <tr> <th class="width-33">1</th> <th class="width-77">2</th> </tr> </thead> </table> </section> <section> <div class="div-parent"> <div class="width-33">1</div> <div class="width-77">2</div> </div> </section> </body> </html>


回答2件
あなたの回答
tips
プレビュー