CSS Reset / Normalize#
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
Layout Structure (Flexbox)#
.container {
width: 1200px;
margin: 0 auto;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
}
Grid Layout Example#
.post-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 30px;
}
Typography Precision#
Font Loading#
function basic_theme_fonts() {
wp_enqueue_style(
'google-fonts',
'https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap',
false
);
}
add_action('wp_enqueue_scripts', 'basic_theme_fonts');
Typography System#
body {
font-family: 'Inter', sans-serif;
font-size: 16px;
line-height: 1.6;
color: #222;
}
h1 { font-size: 40px; font-weight: 700; }
h2 { font-size: 32px; font-weight: 600; }
p { margin-bottom: 20px; }
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header class="site-header">
<div class="container">
<h1 class="logo">
<a href="<?php echo home_url(); ?>">
<?php bloginfo('name'); ?>
</a>
</h1>
<?php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => 'nav',
'menu_class' => 'main-menu'
));
?>
</div>
</header>
function basic_theme_setup() {
register_nav_menus(array(
'primary' => 'Primary Menu'
));
}
add_action('after_setup_theme', 'basic_theme_setup');
Responsive Design#
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@media (max-width: 992px) {
.container {
width: 90%;
}
.post-grid {
grid-template-columns: 1fr 1fr;
}
}
@media (max-width: 600px) {
.post-grid {
grid-template-columns: 1fr;
}
}
Custom Single Template#
<?php get_header(); ?>
<main class="single-post container">
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile;
endif;
?>
</main>
<?php get_footer(); ?>