【发布时间】:2014-06-16 14:56:56
【问题描述】:
我被要求在创建此自定义主题时使用引导 css:
http://crippslawtest.co.uk/news/
我已经把剩下的所有东西都浮起来了(我的意思是所有东西),但无论我做什么,除了我的特色图片(见律师图片)之外,标题和摘录都不会出现。
我发现很难想到某种 css 条件语句,因此无论是否有特色图像,一切都会对齐。
这应该怎么做?你怎么写“如果有特色图片,让标题和摘录的最大宽度为 300 像素”?我不明白,在网上找不到任何相关的东西。
我通过复制我的 Firefox Firebug htmlk 和 css 创建了一个 JS fiddle,它有效,但它不在我的页面上 :( :( :( :
这是我的 CSS:
.floatleft,
.news-page h1,
.news-page header.entry-header,
.news-page .entry-content,
a.post-thumbnail img.attachment-CrippsTheme-full-width,
.news-page .the-categories {
float: left;
}
还有我的 Wordpress 循环:
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
CrippsTheme_post_thumbnail();
echo '<p class="the-date">';
the_date();
echo '</p>';
//Get the categories
echo '<p class="the-categories">';
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
foreach($categories as $category) {
$output .= '<a class="feedcat" href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
}
echo trim($output, $separator);
}
echo '</p>';
// End of get categories
echo '<h1 class="entry-title"><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></h1><br class="c" /><p>';
the_excerpt();
echo '</p>';
echo '<p class="read-more"><a href="';
the_permalink();
echo '">Read More...</a></p><br class="c" />';
endwhile;
CrippsTheme_paging_nav();
else :
get_template_part( 'content', 'none' );
endif;
?>
【问题讨论】:
-
这是你的第一个错误“我把剩下的所有东西都浮起来了(我的意思是所有东西)”。为什么?
-
@Paulie_D 我将所有内容都浮动起来,因为我希望我的标题和摘录文本位于我的特色图片旁边。我能想到的唯一方法是向左浮动?你有什么想法?谢谢。
-
也许您可以在 JSfiddle 中向我们展示一个简化的案例。
-
@Paulie_D 我创建了一个 js 小提琴,我在其中复制了我的 html 和 css,并且小提琴有效!但我的没有!非常混乱:S jsfiddle.net/pu6t3
-
我必须在 php 中为我的 css 编写 if else 吗? :S
标签: html css wordpress twitter-bootstrap