LoginSignup
nnnoot
@nnnoot

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

WP page.phpのみにできる上部の空白について

解決したいこと

WP page.phpのみにできる上部の空白を消したい。

発生している問題・エラー(page.php)

<?php
/*
Template Name:お問い合わせ
 */
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
  <meta charset="<?php bloginfo('charset'); ?>">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>">
  <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <title><?php wp_title('|', true, 'right'); ?><?php bloginfo('name'); ?></title>
  <meta name="description" content="#">
  <link rel="stylesheet" type="text/css" href="css/9-1-2.css">
  <link rel="stylesheet" type="text/css" href="css/5-2-1.css">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Serif+JP:wght@400;700&display=swap" rel="stylesheet">
  <link href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" rel="stylesheet">
  <link rel="shortcut icon" href="<?php echo get_template_directory_uri(); ?>/img/PNG">
<?php wp_head(); ?>
</head>

function.phpは以下です

<?php
function my_scripts() {
    wp_enqueue_style( 'style-name', get_template_directory_uri() . '/css/style.css', array(), '1.0.0', 'all' );
  wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/script.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
add_filter('show_admin_bar', '__return_false');

 
該当部分の写真は以下

スクリーンショット 2021-07-28 12.23.38.png

自分で試したこと

・ツールバーの非表示
・function.phpへadd_filter('show_admin_bar', '__return_false');の記載
・<?php wp_footer(); ?>付与
・全角空白の確認

utf-8確認の仕方がわからず手をつけていません。

ご教示よろしくお願い致します。

0

1Answer

bodyタグには"User agent stylesheets"といって何も指定しなくても、8pxのmarginが適用されます。

bodyに対してmargin: 0;をつけてみてください

0

Your answer might help someone💌