wordpress 如何删除 margin-top: 32px !important 从 22 开始

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25491619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:59:36  来源:igfitidea点击:

how to delete margin-top: 32px !important from twenty twelve

wordpressthemesmargin

提问by uniqueman

I want to remove the margin-top property from twenty twelve theme. This is the default theme provided by wordpress. The sample of the code what I found with the help of firebug.

我想从二十十二个主题中删除 margin-top 属性。这是 wordpress 提供的默认主题。我在萤火虫的帮助下找到的代码示例。

html{
     margin-top: 32px !important;
    }

回答by l2aelba

function remove_admin_login_header() {
    remove_action('wp_head', '_admin_bar_bump_cb');
}
add_action('get_header', 'remove_admin_login_header');

回答by Chad Bonthuys

Add the following function to your functions.php file

将以下函数添加到您的 functions.php 文件中

function my_function_admin_bar(){ return false; }
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

回答by drjorgepolanco

Go to the functions file inside your theme folder:

转到主题文件夹中的函数文件:

functions.php

函数.php

add_action('get_header', 'remove_admin_login_header');

function remove_admin_login_header() {
    remove_action('wp_head', '_admin_bar_bump_cb');
}

回答by Mikepote

A better way to do this is to add theme support for the admin bar with a callback of "return false", then Wordpress wont ever trigger the _admin_bar_bump_cbaction which is responsible for adding in the margin-top:32px.

一个更好的方法是通过“return false”回调为管理栏添加主题支持,然后 Wordpress 将永远不会触发_admin_bar_bump_cb负责添加margin-top:32px.

add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );

回答by sarder kamruzzaman polash

Please try it....

请尝试一下....

html.k-webkit.k-webkit78 { margin-top: 0 !important; }

html.k-webkit.k-webkit78 { margin-top: 0 !important; }

回答by isabelle.G

I think it is because you are logged in in your wordpress account and that 32px space corresponds to the black menu line that is on the top of your page, which doesn't appear but leaves the space for it . Log out and refresh the page and see if it continues or open the website in an other browser.

我认为这是因为您登录了您的 wordpress 帐户,并且该 32px 空间对应于您页面顶部的黑色菜单行,该行没有出现,但为它留下了空间。注销并刷新页面,看看它是否继续或在其他浏览器中打开网站。

回答by M21

in the style.css around line #1645 is body .site { which has padding top & bottom:

在 #1645 行周围的 style.css 中是 body .site {,它具有顶部和底部填充:

body .site {
    padding: 0 40px;
    padding: 0 2.857142857rem;
    margin-top: 48px;
    margin-top: 3.428571429rem;
    margin-bottom: 48px;
    margin-bottom: 3.428571429rem;
    box-shadow: 0 2px 6px rgba(100, 100, 100, 0.3);
}

回答by user6917846

Remove margin from h1 - h6 elements. WP have default margins and that is why you see 32px !Important in inline HTML code.

从 h1 - h6 元素中删除边距。WP 有默认的边距,这就是为什么你会看到 32px !重要的内联 HTML 代码。

回答by GeeDee

I had the same issue. I got rid of

我遇到过同样的问题。我摆脱了

wp_head();

in the header template and problem solved.

在标题模板中,问题解决了。

回答by Eugene Sidash

You can specify an identifier for the html tag in the template and set it to margin-top: 0! important;

您可以为模板中的 html 标签指定一个标识符并将其设置为 margin-top: 0! 重要的;

#html {margin-top: 0 !important;}