Php 如何垂直对齐两个非';t在同一个分区中
我有一个wordpress页面,在论坛内容上方有一个登录小部件Php 如何垂直对齐两个非';t在同一个分区中,php,css,wordpress,Php,Css,Wordpress,我有一个wordpress页面,在论坛内容上方有一个登录小部件。我想将其向右浮动,并使论坛标题在左侧垂直对齐,如下所示: 我遇到的问题是论坛标题是动态生成的,所以我不能将它们放在同一个div中 有什么想法吗 以下是源代码: <div id="primary"> <div id="content" role="main"> <div id='widget-sidebar' class
。我想将其向右浮动,并使论坛标题在左侧垂直对齐,如下所示:
我遇到的问题是论坛标题是动态生成的,所以我不能将它们放在同一个div中
有什么想法吗
以下是源代码:
<div id="primary">
<div id="content" role="main">
<div id='widget-sidebar' class='widgets_on_page'>
<ul><li id="wp_sidebarlogin-2" class="widget widget_wp_sidebarlogin"><h2 class="widgettitle">Welcome Admin</h2><div class="avatar_container"><img src="http://localhost/wordpress/wp-content/plugins/user-avatar/user-avatar-pic.php?src=http://localhost/wordpress/wp-content/uploads/avatars/1/1344255249-bpfull.jpg&w=38&id=1&random=1344255249" alt="" class=" avatar avatar-38 photo user-1-avatar" width="38" height="38" /></div><ul class="pagenav"><li class="page_item"><a href="http://localhost/wordpress/wp-admin/">Dashboard</a></li><li class="page_item"><a href="http://localhost/wordpress/wp-admin/profile.php">Profile</a></li><li class="page_item"><a href=" http://localhost/wordpress/wp-login.php?action=logout&redirect_to=http%3A%2F%2Flocalhost%2Fwordpress%2F%3Fforum%3Dna-forum&_wpnonce=caf8874286">Logout</a></li></ul></li></ul>
</div><!-- widgets_on_page -->
<article id="post-2901" class="post-2901 forum type-forum status-publish hentry">
<header class="entry-header">
<h1 class="entry-title"><a href="http://localhost/wordpress/?forum=na-forum" title="Permalink to NA Forum" rel="bookmark">NA Forum</a></h1>
</header><!-- .entry-header -->
- 欢迎管理员
以下是我正在使用的论坛页面模板的一部分:
<div id="primary">
<div id="content" role="main">
<?php widgets_on_template("widget-sidebar"); ?>
<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
如果您不喜欢IE7,您可以使用
显示:表格单元格垂直对齐容器代码>。由于它呈现为一个表,因此它失去了浮动的能力。因此,必须在至少一个元素上显式设置宽度
CSS
HTML
第一行
第二行
最后一行
只有一行
不停摆弄
对小部件使用绝对定位应该是可行的。比如:
div#content {
position: relative;
}
div#widget-sidebar {
position: absolute;
top: 10px;
right: 10px;
}
<div>
first line<br>
second line<br>
last line
</div>
<div>
just one line<br>
</div>
div#content {
position: relative;
}
div#widget-sidebar {
position: absolute;
top: 10px;
right: 10px;
}