HiveBrain v1.2.0
Get Started
← Back to all entries
patternphpMinor

Adding flair to PHP page with Sassy (SCSS)

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
withphpaddingsassypageflairscss

Problem

This is what I've done so far:

$block-height: 180px;

@mixin block {
    float: left;
    margin-bottom: 20px !important;
    margin-right: 20px !important;
    overflow: hidden;
}

#content h2 {
    height: 30px;
}

#top-bar {
    overflow: hidden;
}

.block-1 {
    @include block;
    width: 340px;
    height: 390px;
    h2 {
        color: #555;
        font-size: 28px;
        font-weight: 400;
        line-height: 120%;
    }
}

.block-2 {
    @include block;
    width: 340px;
    height: $block-height;
}

.block-3 {
    @include block;
    width: 160px;
    height: $block-height;
}


HTML:

```

query('post_type=page_content&locations=Front Page&page_sections=Profile');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>












query('post_type=page_content&locations=Front Page&page_sections=Themep');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>

" title="" rel="bookmark">


query('post_type=page_content&locations=Front Page&page_sections=ThemeCL');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>

" title="" rel="bookmark">




query('post_type=page_content&locations=Front Page&page_sections=Theme Child Right');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>

" title="" rel="bookmark">





query('post_type=page_content&locations=Front Page&page_sections=FromBlog');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>

" title="" rel="bookmark">
" title="" rel="bookmark">

ID, "Other_Work", true); ?>



query('post_type=page_content&locations=Fro

Solution

It looks a bit like block-1's height is calculated from @block-height, in which case I would do that calculation rather than putting in a literal value. This way if you change @block-height, block-1 will adjust with it.

Beyond Sass and efficiency, I would also advise you to think again about the class names block-1, block-2 and block-3. If there will only be one of each of these on a page then use IDs rather than classes and name them after the content (eg. site-nav-block or article-block). If there will be more than one then give it a class name and name it after the content type (eg. nav-item or article-summary).

This will be much less confusing for a third party like myself to read, and indeed for you as your page gets bigger and requires more styling.

Context

StackExchange Code Review Q#634, answer score: 6

Revisions (0)

No revisions yet.