0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[React] iPad用WEBアプリ開発でのCSS調整!

Posted at

はじめに

iPad用のWEBアプリに便利なCSSの調整方法について紹介します!
今回は、ダミーとしてラジオボタンの調整も行います!

1. iPad用フィールドの作成

まず、元となるフィールドを作成します!
CSSの為に、各要素にclassを設定しています!


import React, { useState } from "react";
import styles from "../styles/MyComponent.module.css";

const MyComponent = () => {
  const [selectedOption, setSelectedOption] = useState("option1");

  const handleOptionChange = (event) => {
    setSelectedOption(event.target.value);
  };
  return (
    <div class={styles.content}>
      <div class={styles.box}>
        <h1>Radio Buttons in Next.js</h1>

        <label class={styles.radioLabel}>
          <input
            type="radio"
            value="option1"
            checked={selectedOption === "option1"}
            onChange={handleOptionChange}
          />
          Option 1
        </label>

        <label class={styles.radioLabel}>
          <input
            type="radio"
            value="option2"
            checked={selectedOption === "option2"}
            onChange={handleOptionChange}
          />
          Option 2
        </label>

        <label class={styles.radioLabel}>
          <input
            type="radio"
            value="option3"
            checked={selectedOption === "option3"}
            onChange={handleOptionChange}
          />
          Option 3
        </label>

        <p>Selected Option: {selectedOption}</p>
      </div>
    </div>
  );
};

export default MyComponent;

2. CSSファイルを調整

次に、CSSを設定していきます!
iPad用に、820×1180pxで調整しています!

/* MyComponent.module.css */
.box {
    background: #eee;
    width: 820px;
    height: 1180px;
  }
  
  .content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .radioLabel {
    display: block;
    margin-bottom: 10px;
    margin-left: 5%;
  }

image.png

まとめ

このように設定することで、boxの領域が、iPad用のスペースとなりました!
今回の記事を参考に、iPad用のwebアプリ開発を行ってみてください!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?