【问题标题】:Css: Wordpress & Boostrap: Styling the Posts Page's featured imageCss:Wordpress 和 Bootstrap:样式化帖子页面特色图片
【发布时间】:2014-06-16 14:56:56
【问题描述】:

我被要求在创建此自定义主题时使用引导 css:

http://crippslawtest.co.uk/news/

我已经把剩下的所有东西都浮起来了(我的意思是所有东西),但无论我做什么,除了我的特色图片(见律师图片)之外,标题和摘录都不会出现。

我发现很难想到某种 css 条件语句,因此无论是否有特色图像,一切都会对齐。

这应该怎么做?你怎么写“如果有特色图片,让标题和摘录的最大宽度为 300 像素”?我不明白,在网上找不到任何相关的东西。

我通过复制我的 Firefox Firebug htmlk 和 css 创建了一个 JS fiddle,它有效,但它不在我的页面上 :( :( :( :

http://jsfiddle.net/pu6t3/

这是我的 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


【解决方案1】:

试试这个

http://jsfiddle.net/pu6t3/1/

在段落的开头添加图像(在文本之前,但在“p”标签之后)和 为图像添加一些样式并留有一些边距,使其可读。

<p class="the-date">

 <a class="post-thumbnail" href="http://crippslawtest.co.uk/top-25-law-firms/">
 <img width="270" height="192" style="float:left;margin:0 25px 0 0;" src="http://crippslawtest.co.uk/wp-content/uploads/2014/04/featured-one.jpg" class="attachment-CrippsTheme-full-width wp-post-image" alt="featured-one" /></a>
 April 21, 2014

<a class="feedcat" href="http://crippslawtest.co.uk/category/news/" title="View all posts in News">News</a> <a class="feedcat" href="http://crippslawtest.co.uk/category/press-coverage/" title="View all posts in Press Coverage">Press Coverage</a> <a class="feedcat" href="http://crippslawtest.co.uk/category/reports/" title="View all posts in Reports">Reports</a>
<h1 class="entry-title"><a href="http://crippslawtest.co.uk/top-25-law-firms/">Cripps named one of Top 25  law firms in UK</a>
</h1><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus, metus non mattis pretium, felis diam vehicula leo, ac condimentum orci mi sit amet nisl. Nulla facilisi. Pellentesque pellentesque dui ac facilisis varius. Morbi porta luctus arcu, id vulputate dui pellentesque et. Sed eget nunc sit amet elit euismod auctor et ut nibh. Nullam in [&hellip;]</p>

我刚刚大致复制了您的源代码。 但主要思想是在“p”标签之后添加图像并添加样式。

【讨论】:

  • 嗨 Manu,我通过添加 CrippsTheme_post_thumbnail(); 在我的 php 循环中尝试了您的解决方案;在我的 p 日期标签之后,但它不起作用:( 不过感谢您的回复。
猜你喜欢
  • 2019-03-22
  • 2019-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-08
相关资源
最近更新 更多