質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
JSP

JSP(Java Server Pages)とは、ウェブアプリケーションの表示レイヤーに使われるサーバーサイドの技術のことです。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

Q&A

解決済

2回答

3451閲覧

table内の文字がずれる

K_3578

総合スコア1282

JSP

JSP(Java Server Pages)とは、ウェブアプリケーションの表示レイヤーに使われるサーバーサイドの技術のことです。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

0グッド

0クリップ

投稿2021/01/23 02:16

前提・実現したいこと

画面上で<th><td>内の文字がずれて表示されるので
全てセル内に収まるようにしたいです。

該当のソースコード

CSS

1@CHARSET "UTF-8"; 2 3body { 4 color: #333333; 5 font-family: "Hiragino Kaku Gothic Pro",Meiryo,"MS PGothic",Helvetica,Arial,sans-serif; 6} 7 8#header { 9 width: 100%; 10 height: 70px; 11 background-color: #333333; 12} 13 14#content { 15 width: 94%; 16 margin-top: 15px; 17 padding-left: 3%; 18} 19 20h1 { 21 width: 94%; 22 padding-top: 17px; 23 padding-left: 3%; 24 font-size: 24px; 25 display: inline; 26 color: #eeeeee; 27} 28 29th { 30 width: 50%; 31 padding: 10px 2%; 32 text-align:center; 33} 34 35td { 36 width: 66%; 37 padding: 10px 2%; 38 text-align:center; 39} 40h2 { 41 font-size: 36px; 42 margin-bottom: 15px; 43} 44 45li { 46 margin-top: 10px; 47 margin-bottom: 10px; 48} 49 50p { 51 margin-top: 15px; 52 margin-bottom: 15px; 53} 54 55a { 56 text-decoration: none; 57 color: #24738e; 58} 59table, tr, th, td { 60 border: 1px solid #cccccc; 61} 62th,td { 63 white-space: nowrap; 64 65} 66 67table { 68 width: 100%; 69 table-layout: fixed; 70} 71button { 72 font-size: 14px; 73 padding: 5px 10px; 74} 75 76#footer { 77 text-align: center; 78} 79#flush_success { 80 width: 100%; 81 padding-top: 28px; 82 padding-left: 2%; 83 padding-bottom: 28px; 84 margin-bottom: 15px; 85 color: #155724; 86 background-color: #d4edda; 87} 88#flush_error { 89 width: 100%; 90 padding-top: 28px; 91 padding-left: 2%; 92 padding-bottom: 28px; 93 margin-bottom: 15px; 94 color: #721c24; 95 background-color: #f8d7da; 96} 97table.employee_list th { 98 width: 30%; 99 padding: 10px 2%; 100} 101 102 103#header a { 104 color: #eeeeee; 105} 106table.Truck_table th.space1{ 107 width:200px; 108 position:sticky; 109 top:0; 110 left:0; 111 z-index: 5; 112back-ground-color: #808080; 113} 114table.Truck_table thead th { 115 position: -webkit-sticky; 116 position: sticky; 117 white-space: nowrap; 118} 119.Truck_table thead tr:nth-child(1) th { 120 top: 0; 121} 122.Truck_table thead tr:nth-child(2) th { 123 top: 1.5rem; /* 2行目は1行目の高さの位置に固定する */ 124} 125table.Truck_table{ 126 width:300%; 127 padding: 10px 2%; 128 overflow: scroll; 129} 130h1 a { 131 color: #eeeeee; 132} 133h1 { 134 font-size: 24px; 135 display: inline; 136} 137pre { 138 font-family: "Hiragino Kaku Gothic Pro",Meiryo,"MS PGothic",Helvetica,Arial,sans-serif; 139} 140h3 { 141 font-size: larger; 142

JSP

1<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 2<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 4 5 6<c:import url="/WEB-INF/views/layout/app.jsp"> 7 <c:param name="content"> 8 <c:if test="${flush != null}"> 9 <div id="flush_success"> 10 <c:out value="${flush}"></c:out> 11 </div> 12 </c:if> 13 <h2>車両 一覧</h2> 14 15 <p><a href="<c:url value='/dispatch/new' />">新規登録</a></p> 16 <p><a href="<c:url value='/dispatch/edit' />">登録情報変更</a></p> 17 18 <table class="Truck_table"> 19 <thead> 20 <tr> 21 <th class="space1" rowspan="2" colspan="4"></th> 22 <% 23 for (int i =0; i<31; i++){ 24 out.println("<th class='date' colspan='4'>" + "1月"+(i+1)+"日" + "</th>"); 25 } 26 %> 27 </tr> 28 <tr> 29 30 <th>宵積卸地</th> 31 <th>積地</th> 32 <th>卸地</th> 33 <th>宵積</th> 34 35 </tr> 36 </thead> 37 38<c:if test="${Trucks.task_date == date}" var="flg"/> 39 40<c:if test="${flg}"> 41 42<c:forEach var="trucks" items="${trucks}" varStatus="status"> 43 44 <tbody> 45 46 <tr> 47 <td class="office_name" rowspan="4"><c:out value="${trucks.office_name}"></c:out></td> 48 <td class="truck_code" colspan="2" rowspan="4"><c:out value="${trucks.truck_code}"></c:out></td> 49 <td class="truck_type" rowspan="4"><c:out value="${trucks.truck_type}"></c:out></td> 50 51 52 53 <td class="mw_time"><c:out value="${trucks.mw_time}"></c:out></td> 54 <td class="sa_time"><c:out value="${trucks.sa_time}"></c:out></td> 55 <td class="wa_time"><c:out value="${trucks.wa_time}"></c:out></td> 56 <td class="es_time"><c:out value="${trucks.es_time}"></c:out></td> 57 58 </tr> 59 <tr> 60 <c:forEach begin="1" end="31"> 61 <td class ="宵積卸地"><c:out value="${trucks.m_wholesale_area}"></c:out></td> 62 <td class ="積地"><c:out value="${trucks.stack_area}"></c:out></td> 63 <td class ="卸地"><c:out value="${trucks.wholesale_area}"></c:out></td> 64 <td class ="宵積"><c:out value="${trucks.e_stack_area}"></c:out></td> 65 </c:forEach> 66 </tr> 67 <tr> 68 69 <td class="mw_time"></td> 70 <td class="sa_time"></td> 71 <td class="wa_time"></td> 72 <td class="es_time"></td> 73 74 </tr> 75 <tr> 76 77 <td class ="宵積卸地"></td> 78 <td class ="積地"></td> 79 <td class ="卸地"></td> 80 <td class ="宵積"></td> 81 </tr> 82 </tbody> 83 </c:forEach> 84 </c:if> 85 <c:if test="${!flg }"> 86 <c:if test="${flg==null}"> 87 <div id="flush_error"> 88 入力内容にエラーがあります。<br /> 89 <c:out value="${error}" /><br /> 90 </div> 91 </c:if> 92 </c:if> 93 </table> 94 95 </c:param> 96</c:import>

##実際の画面
イメージ説明

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2021/01/23 02:49 編集

モック作ってからやらないからでは。 html,cssに絶対の自信があるのならいいんですが。
guest

回答2

0

ベストアンサー

white-space: nowrap;
をコメントアウトするか、セルの幅を調整する、ですかね。

そもそもこの CSS はどこから持ってきたんでしょうか。
理解していない CSS を全部コメントアウトしてから始めてはどうでしょう。

投稿2021/01/23 02:41

68user

総合スコア2005

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

K_3578

2021/01/25 01:27

回答ありがとうございます。 返信が大幅に遅れてしまって申し訳ありません。 一度、コメントアウトの方、試してみます
guest

0

自分でスタイルシートを書き直して見たところずれを解消できました。

投稿2021/01/25 04:35

K_3578

総合スコア1282

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問