実現したいこと
発生している問題・分からないこと
レスポンシブ対応後でもレスポンシブ対応前と同じような表を作成したのですが、どうしても、黒色の長方形の要素が変わってしまいます、どのようなコードを入力するとレスポンシブ対応前後で同じような表を作成することができるでしょうか。
また、max-width: 821;の際には表の形を他の物にした方がいいのか教えてください、よろしくお願いします。
回答のコードを入力後
リンク内容
該当のソースコード
https://codepen.io/Yg-K-the-typescripter/pen/mdNKdeK
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
marginやpaddingを調整して要素の左端をそろえたが適用されない箇所があり微妙にそろわなくなった。
補足
特になし
ご提示のリンク先を見ましたが、スクリーンショットとは違う感じの表示でした。
「レスポンシブ対応後」のスクリーンショットでは、2行目の「イベント」などが左に合っていますが、リンク先では右に合っていました。これはリンク先の方を見て回答して大丈夫ですか?
vscodeとcode.penで表示が異なってしまっているようなので、リンク先の方をみて回答をお願いします。
もしかして、リンク先、というのは codepen のことではないのかな……?
そうであるならば、コードをご提示ください。
https://prod.liveshare.vsengsaas.visualstudio.com/join?637A4F6CCDA14DDC3BE7ECCE56E3C2CF3BB9
返答遅れてすいません、こちらvscodeのコードでございます。
live share は共同セッション系なのでそれでタイミング不一致するようなこの環境で使うのは無茶では……
やるなら gist とか github とかにソースを上げて確認してもらうとかそっちの方がいいのではないでしょうか……?
(まぁ、codepen で思った感じに動かないならそっちしかない気がしますが。
HTML
<div class="info-table">
<div class="info-boxes"></div><!-- /.info-boxes -->
<div class="item">
<span class="item-time">2023.04.01</span>
<span class="item-ttl">休診情報</span>
<span class="item-txt">2023年4月の休診日は5日、17日、27日となります。</span>
</div>
<div class="item">
<span class="item-time item-time-2">2022.12.24</span>
<span class="item-ttl item-ttl-2">イベント</span>
<span class="item-txt item-txt-2">当院でクリスマスイベントを行います。南高校吹奏楽団をお呼びして、ロビーコンサートを開催予定です。</span>
</div>
<div class="item">
<span class="item-time">2022.12.11</span>
<span class="item-ttl item-ttl-3">採用</span>
<span class="item-txt item-txt-3">当院では臨床検査技師を募集しております。詳しい福利厚生についてご説明させていただきます。当院で働く…</span>
</div>
<div class="item">
<span class="item-time item-time-4">2022.12.11</span>
<span class="item-ttl item-ttl-4">イベント</span>
<span class="item-txt">ホームページをリニューアルしました。</span>
</div>
<div class="cta-btn-txt">すべて見る <i class="fa-solid fa-play"></i></div>
</div><!-- /.info-boxes -->
</div><!-- /.info-table -->
CSS
.info-table {
width: 1180px;
height: 390px;
background-color: #fff;
border-radius: 30px;
margin: 0 1px 113px 1px;
padding: 48px 66px 46px 66px;
}
@media screen and (max-width: 821px) {
.info-table {
width: 100%;
height: auto;
}
.item-ttl {
font-size: 80%;
height: auto;
}
}
.item {
display: flex;
margin: 18px 0;
border-bottom: 2px solid #E7E7E7;
width: 100%;
padding-bottom: 18px;
}
@media screen and (max-width: 821px) {
.item {
align-items: center;
}
}
.item:first-child {
margin-top: 0;
}
.item:last-child {
margin-bottom: 0;
}
.item-time .item-time-4 {
margin-right: 30px;
color: #21A937;
font-size: 16px;
font-weight: bold;
}
@media screen and (max-width: 821px) {
.item-time-4 {
margin-right: 15px;
}
}
.item-ttl {
margin-right: 30px;
background-color: #444444;
color: #fff;
font-size: 12px;
font-weight: bold;
text-align: center;
width: 80px;
height: 25px;
padding: 4px 16px;
display: inline;
flex: none;
}
@media screen and (max-width: 821px) {
.item-ttl-2 {
width: 80px;
height: 25px;
padding-right: 0;
margin-right: 0;
}
.item-ttl-3 {
}
.item-ttl-4 {
margin-left: 0;
}
}
.item-txt {
font-size: 16px;
font-weight: bold;
}
@media screen and (max-width: 821px) {
.item-txt-2 {
}
}
@media screen and (max-width: 821px) {
.item-txt {
font-size: 50%;
}
.item-txt-3 {
}
}
.item:last-child {
margin-bottom: 21px;
}
.item:first-child {
margin-top: 0;
}
.item-time {
font-size: 16px;
font-weight: bold;
color: #21A937;
margin-right: 30px;
}
.item-ttl {
width: 80px;
height: 25px;
background-color: #444444;
color: #fff;
font-size: 12px;
font-weight: bold;
padding: 4px 16px;
margin-right: 30px;
display: inline;
}
.item-txt {
font-size: 16px;
font-weight: bold;
color: #444444;
}
.cta-btn-txt {
font-size: 16px;
font-weight: bold;
float: right;
color: #444444;
質問文内に ``` で囲って 書いてください!コメント内に直接ソース書く場合、インデント等に問題があるので質問文等のスタイルの利く場所で書いてください!
https://teratail.com/help#about-markdown
わかりました、ありがとうございます。
回答でも書いていますが、 destyle.css と style.css のどちらが記載されていないのでしょうか?(css として書いていないのはどっちでしょうか?
juner さんはご存じの上であえて質問なさってそうですが、destyle.css はおそらくリセットCSSの一種ですね。結構尖ったリセットの仕方をするので初心者向けではないと思うのですが、なぜこれを選んでしまったのか。
https://nicolas-cusan.github.io/destyle.css/




