在wordpress/php中,如何在同一行中对齐标题和当前日期?
我有一个html/php代码,如下所示: 代码A:在wordpress/php中,如何在同一行中对齐标题和当前日期?,php,html,css,wordpress,Php,Html,Css,Wordpress,我有一个html/php代码,如下所示: 代码A: <header class="entry-header container"> <?php the_title('<h1 class="entry-title" id="page-entry-title">', '</h1>'); ?> </header><!-- .entry-header --> 代码B: <header class="entry-hea
<header class="entry-header container">
<?php the_title('<h1 class="entry-title" id="page-entry-title">', '</h1>'); ?>
</header><!-- .entry-header -->
代码B:
<header class="entry-header container">
<?php the_title('<h1 class="entry-title" id="page-entry-title">', '</h1>'); ?>
</header><!-- .entry-header -->
这是我将用于获取当前日期的函数:
echo date('y-m-d')
问题陈述:
<header class="entry-header container">
<?php the_title('<h1 class="entry-title" id="page-entry-title">', '</h1>'); ?>
</header><!-- .entry-header -->
我想知道是否有任何方法集成代码A和代码B,以便将标题和日期显示在同一行中 你的css:
条目标题{
字号:18px;
字体大小:1.8rem;
背景#3c3f47;
}
参赛作品名称{
字体大小:1.8rem;
颜色:#FFF;
保证金:0;
填充:1.2rem 0;
显示:内联;
}
标题
在这里约会
在这里约会
在span中换行,或者如果要使用h1标记,请将显示设置为内联块
参议院门户
1966年7月6日
只需在_title()函数旁边添加echo,并使h1标记显示inline块,这样它就不会占用整个页眉宽度。(为语义添加了日期标记,但不是必需的)
PHP:
显示:内联块@Dilek我想知道你是否可以修改代码。你是不是在问你应该把回音日期放在PHP中的什么地方?如果是这样的话,请看我的答案。我应该在代码A中提到
echo date('y-m-d')
。@flash您不需要将类添加到h1条目标题中,因为h1在该类中,所以它将执行您想要的操作。
.entry-header {
font-size: 18px;
font-size: 1.8rem;
background: #3c3f47;
display: block;
}
.entry-title {
font-size: 1.8rem;
color: #FFF;
margin: 0;
padding: 1.2rem 0;
display: inline-block;
}