i have a menu in the left and i want the site-content resize by changing the screen size. actually like in https://myspace.com/
what i have now:
the menu in the left side. this is the code:
.main-navigation {
background-color: #000000;
border-left: 1px solid #cccccc;
display: block;
float: left;
font-family: "Open Sans Condensed", Helvetica, Arial, sans-serif;
font-weight: normal;
max-width: 50%;
position: absolute;
top: 85px;
width: 150px;
height: auto;
text-align: right;
text-transform: capitalize;
}
the site-content i putted margin-left 150px to put the content after the menu because if not, the content is under the menu. :
.blog .site-content,
.archive .site-content,
.search .site-content {
margin: 0 auto;
max-width: 885px;
position: relative;
left: 0px;
margin-left: 150px;
}
and the article that inside:
.blog .site-content .hentry,
.archive .site-content .hentry,
.search .site-content .hentry {
float: left;
margin: 0;
overflow: hidden;
width: 295px;
height: 295px;
}
the main-index is:
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', 'home' );
?>
<?php endwhile; ?>
<?php pictorico_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>
the nav(menu) is in the header so the header:
<?php wp_head(); ?>
>
<header id="masthead" class="site-header" role="banner">
<div class="site-header-inner">
<div class="site-branding">
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
</div>
<nav id="site-navigation" class="main-navigation" role="navigation">
<h1 class="menu-toggle"><span class="screen-reader-text"><?php _e( 'Menu', 'pictorico' ); ?></span></h1>
<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'pictorico' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
</nav><!-- #site-navigation -->
<div class="header-search">
<?php get_search_form(); ?>
</div>
</div>
</header><!-- #masthead -->
<?php if ( is_home() && pictorico_has_featured_posts( 1 ) ) : ?>
<?php get_template_part( 'content', 'featured' ); ?>
<?php elseif ( get_header_image() && ( is_home() || is_archive() || is_search() ) ) : ?>
<div class="hentry has-thumbnail">
<div class="entry-header">
<div class="header-image" style="background-image: url(<?php header_image(); ?>)">
<span class="screen-reader-text"><?php bloginfo( 'name' ); ?></span>
</div>
</div>
</div>
<?php endif; ?>
<div id="content" class="site-content">
It's a bit late to implement now, but next time look at something like Bootstrap or Zurb Foundation for frameworks that make it really fast to build responsive web apps. They take away the need for complicating things with media queries. Just a thought
Your content is not going to re-size because you have given it a fixed width (295px). Since you floated them, they should just re-arrange themselves based on how much room there is in site-content.
If you actually want the articles to re-size, give them percentage widths. Then, as site-content changes width, they will also.
If you want to keep the aspect ratio (height/width), then you need a wrapper that maintains the aspect ratio using % padding and put the content in it using postion: absolute. See, for example, Maintain the aspect ratio of a div with CSS.
Related
I got this problem which my limited capabilities can´t handle. I tried to use the near solutions but does not work the way I expected.
In the post nav previous link I want to retrieve the thumbnail image link and text over the image and make the whole thing clickable and zoom in on it while hovering. Like in the end of http://swordandscale.com/sword-and-scale-episode-100/. But I only manage to get the text. Here is my function,
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-10 col-lg-8 col-lg-offset-2 col-md-offset-1">
<?php
if( have_posts() ):
while( have_posts() ): the_post();
sidekick_save_post_views( get_the_ID() );
get_template_part( 'template-parts/single', get_post_format() );
echo sidekick_post_navigation();
if ( comments_open() ):
comments_template();
endif;
endwhile;
endif;
?>
</div><!-- .col-xs-12 -->
</div><!-- .row -->
</div><!-- .container -->
</main>
</div><!-- #primary -->
/*
========================
SINGLE POST CUSTOM FUNCTIONS
========================
*/
function sidekick_post_navigation(){
$nav = '<div class="row">';
$prev = get_previous_post_link( '<div class="post-link-nav">%link</div>', '%title' );
$nav .= '<div class="col-xs-12 text-center">' . $prev . '</div>';
$next = get_next_post_link( '<div class="post-link-nav">%link</div>', '%title' );
$nav .= '<div class="col-xs-12 text-center">' . $next . '</div>';
$nav .= '</div>';
return $nav;
}
First thing you need to do is open your theme’s single.php file and add the following code inside the loop most likely after the_content() area:
<div id="cooler-nav" class="navigation">
<?php $prevPost = get_previous_post(true);
if($prevPost) {?>
<div class="nav-box previous">
<?php $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(100,100)
);?>
<?php previous_post_link('%link',"$prevthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php } $nextPost = get_next_post(true);
if($nextPost) { ?>
<div class="nav-box next" style="float:right;">
<?php $nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(100,100) );
} ?>
<?php next_post_link('%link',"$nextthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php } ?>
</div><!--#cooler-nav div -->
Next thing you need to do is open your style.css file and add the following styles:
#cooler-nav{clear: both; height: 100px; margin: 0 0 70px;}
#cooler-nav .nav-box{background: #e9e9e9; padding: 10px;}
#cooler-nav img{float: left; margin: 0 10px 0 0;}
#cooler-nav p{margin: 0 10px; font-size: 12px; vertical-align: middle;}
#cooler-nav .previous{float: left; vertical-align: middle; width: 250px;
height: 100px;}
#cooler-nav .next{float: right; width: 250px;}
Feel free to change the styling to match it with your theme. Often our users like to style the code, so it makes it easier for them to tweak it. This is just basic styling which you should be able to customize easily.
If you want to change the thumbnail size, then simply change the array(100,100) to whatever you like.
hope that is usefull for you .
I have a problem when making a wordpress theme cannot responsive when zooming and open on Internet Explorer/Edge and got worst result after tested on many devices like screenshot below:
Cannot compatible with IE/Edge:
Cannot responsive when zooming:
Index.php
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package test
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php endif; ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', get_post_format() );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Header.php
<?php
/**
* The header for our theme.
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* #link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* #package test
*/
global $woocommerce;
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="container">
<div id="page" class="hfeed site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'gg' ); ?></a>
<header id="masthead" class="site-header" role="banner">
<nav id="site-navigation" class="main-navigation2" role="navigation">
<button class="menu-toggle" aria-controls="top-menu" aria-expanded="false"><?php esc_html_e( 'Top Menu', 'gg' ); ?></button>
<ul class="mini-cart">
<li> <a href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" title="<?php esc_attr_e('View your shopping cart'); ?>" class="cart-parent">
<div class="bubblex">
<div class="inside">
<div class="inside-text">
<?php
echo sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count), $woocommerce->cart->cart_contents_count);
?></div>
</div>
</div>
<i class="cart_control">::before</i></a>
<?php
echo '<ul class="cart_list">';
echo '<li class="cart-title"><b>Isi Keranjang:</b></li>';
if (sizeof($woocommerce->cart->cart_contents)>0) : foreach ($woocommerce->cart->cart_contents as $cart_item_key => $cart_item) :
$_product = $cart_item['data'];
if ($_product->exists() && $cart_item['quantity']>0) :
echo '<li class="cart_list_product"><a href="' . esc_url( get_permalink( intval( $cart_item['product_id'] ) ) ) . '">';
/* echo $_product->get_image(); */
echo apply_filters( 'woocommerce_cart_widget_product_title', $_product->get_title(), $_product ) . '</a>';
if($_product instanceof woocommerce_product_variation && is_array($cart_item['variation'])) :
echo woocommerce_get_formatted_variation( $cart_item['variation'] );
endif;
echo '<span class="quantity">' . $cart_item['quantity'] . ' × ' . woocommerce_price( $_product->get_price() ) . '</span></li>';
endif;
endforeach;
else: echo '<li class="empty">' . __( 'Keranjang kosong') . '</li>'; endif;
if ( sizeof( $woocommerce->cart->cart_contents ) > 0 ) :
echo '<li class="total">';
echo '<span class="amount2">Subtotal</span>' . $woocommerce->cart->get_cart_total() . '</li>';
echo '<p class="buttons">Detail Checkout</p>';
endif;
echo '</ul>';
?>
</li> </ul>
<?php wp_nav_menu( array( 'theme_location' => 'top', 'menu_id' => 'top-menu' ) ); ?>
</nav><!-- #site-navigation -->
<div class="site-branding">
<?php if ( is_front_page() && is_home() ) : ?>
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<?php else : ?>
<p class="site-title"><?php bloginfo( 'name' ); ?></p>
<?php endif; ?>
<p class="site-description"><?php bloginfo( 'description' ); ?></p>
</div><!-- .site-branding -->
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', 'gg' ); ?></button>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'primary-menu' ) ); ?>
</nav><!-- #site-navigation -->
</div><!-- #site-wrapper -->
</header><!-- #masthead -->
<div id="content" class="site-content">
Style.css
body {
/* margin: 0 170px 0 20px; */
max-width: 100%;
background: #fff;
margin-left: auto;
margin-right: auto;
}
body {
background-image: url('img/background.png');
background-size: 960px 1600px;
background-repeat: no-repeat;
background-position: top center;
background-attachment: scroll;
}
#media only screen and (max-width: 1200px)
#content {
background-color: #FFFFFF;
}
site-content {
margin: 107px 23.5%;
}
.main-navigation2 {
float: none;
height: 59px;
margin: -18px 196px;
font-size: 12px;
/* font-style: normal; */
}
For further information please check out on development link.
So how I can fix it?
Apply some global styles without media queries then work backwards depending on resolution needs with media queries.
I made some minor changes to your css while viewing in 1200 wide and it fixed the menu issue perfectly. When zooming, it defaulted to the relevant media query.
.main-navigation {
width: 960px;
margin: auto;
}
.menu-primary-menu-container {
margin: 0 0 0 200px;
float: right;
}
ul#primary-menu {
margin: 0px;
}
.main-navigation li {
float: left;
}
.main-navigation a {
padding: 4px 29px 0 16px;
display: block;
text-decoration: none;
/* line-height: 50px; */
color: #000;
font-family: sans-serif;
font-weight: bold;
font-size: small;
}
Bootstrap is a better approach, but I see you've already put some fair amount of work into this theme. This might not be a complete solution, but in theory if you make some minor adjustments as I did below, you can then adjust them as needed for varying viewport sizes in CSS media query.
I'm trying to pull the 4 most recent posts from category "3" to be displayed within a 1000px div, but have each single post display in a 280px div and have them displayed inline.
Right now, my code pulls the recent posts, but only styles the one most recent post.
Here is the current URL: http://dylanpolniak.com/clients/c&c/
Here is my code:
<div id="music">
<h1>Music</h1>
<div class="hr_dark"></div>
<div id="posts">
<?php query_posts('showposts=4&cat=3'); ?>
<div class="single_post">
<?php the_content(); if (have_posts()) : while (have_posts()) : the_post(); if ( has_post_thumbnail() ) {
// check if the post has a Post Thumbnail (featured image) assigned to it.
the_post_thumbnail(); the_title('<h4>', '</h4>');
} ?>
</div>
<?php endwhile; else : endif; ?>
<div class="hr_dark"></div>
<h2>View All</h2>
<style>
#posts { width: 1000px; margin: auto; }
.single_post { width: 280px; height: 400px; position: relative; display: inline-block; float: left; }
h4 { font-size: 20px; font-family: 'Satisfy', cursive; color: #202e31; text-align: center; font-weight: 400; }
</style>
Try putting you class div inside of the while loop, and you have you#posts div unclosed.
Change your code like this:
<div id="posts">
<?php query_posts('showposts=4&cat=3');
the_content(); if (have_posts()) : while (have_posts()) : the_post();
if(has_post_thumbnail() ) { ?>
<div class="single_post"> <?php
// check if the post has a Post Thumbnail (featured image) assigned to it.
the_post_thumbnail(); the_title('<h4>', '</h4>'); ?>
</div>
<?php
} ?>
</div> //add this closing div tag!
I added the text "MENY" next to the toggle (nav trigger) since I thought it would be confusing for desktop visitors when visiting my site. However I can't seem to get the text to line up nicely with the toggle icon. How do I lower or raise the text next to the icon so it looks good?
Here's the .php:
<a href="#" id="nav-trigger">
<span style="font-family: Source Sans Pro; font-size: 16px; line-height: 1; margin-left: 5px; font-weight: 700;">MENY</span> m
Image of issue can be found here: [a link]http://i41.tinypic.com/2jd3l9k.png (not enough rep to add images)
Also, if there's a way to bring them closer together... but that's just a bonus!
Thanks for all help! I'm a beginner trying to learn. :)
Entire header.php >nav-trigger<
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php thb_body_start(); ?>
<div id="page">
<?php thb_header_before(); ?>
<header id="header">
<?php thb_header_start(); ?>
<div class="header-container">
<div class="wrapper">
<?php
$logo = thb_get_option('main_logo');
$logo_2x = thb_get_option('main_logo_retina');
if( !empty($logo['id']) && !empty($logo_2x['id']) ) : ?>
<?php $logo_metadata = wp_get_attachment_metadata($logo['id']); ?>
<style>
#media all and (-webkit-min-device-pixel-ratio: 1.5) {
#logo {
background-image: url('<?php echo thb_image_get_size($logo_2x['id'], 'full'); ?>');
background-size: <?php echo $logo_metadata['width']; ?>px, <?php echo $logo_metadata['height']; ?>px;
}
#logo img { visibility: hidden; }
}
</style>
<?php endif;
?>
<h1 id="logo">
<a href="<?php echo home_url(); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
<?php if( isset($logo['id']) && $logo['id'] != '' ) : ?>
<img src="<?php echo thb_image_get_size($logo['id'], 'full'); ?>" alt="">
<?php else : ?>
<?php bloginfo( 'name' ); ?>
<?php endif; ?>
</a>
</h1>
<?php thb_nav_before(); ?>
<a href="#" id="nav-trigger">
<span style="font-family: Source Sans Pro; font-size: 16px; line-height: 1; margin-left: 5px; font-weight: 700;">MENY</span> m
<div class="nav-wrapper">
<nav id="main-nav" class="main-navigation primary">
<?php thb_nav_start(); ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
<?php thb_nav_end(); ?>
</nav>
<nav id="mobile-nav" class="main-navigation primary">
<?php thb_nav_start(); ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
<?php thb_nav_end(); ?>
</nav>
</div>
<?php thb_nav_after(); ?>
</div>
</div>
<div class="wrapper">
Create a div with the image in it.
Create a div with the text in it.
<div class='myimage'><img src='yourimg'></div>
<div class='menytext'>meny</div>
.menytext{float:left;margin:0 0 0 -50px} (for example)
Float the text div over the image and then you will be able to position the text however you like.
because inline tag has a space, you can add between them, like
<a href="#" id="nav-trigger"><!--
--><span style="font-family: Source Sans Pro; font-size: 16px; line-height: 1; margin-left: 5px; font-weight: 700;">MENY</span>
I have a wordpress page with a login widget <div id='widget-sidebar' class='widgets_on_page'> above the forum content. I would like to float it to the right and have the forum title to align vertically on the left, like this:
The problem I am having is that the forum title is generated dynamically and so I can't place them in the same div.
Any ideas?
Here is the source code:
<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">Dashboard</li><li class="page_item">Profile</li><li class="page_item">Logout</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">NA Forum</h1>
</header><!-- .entry-header -->
Here is the part of my forum page template that I'm working with:
<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' ); ?>
Using absolute positioning for the widget should work. Something like:
div#content {
position: relative;
}
div#widget-sidebar {
position: absolute;
top: 10px;
right: 10px;
}
If you don't care for IE7 you can align container vertically using display: table-cell;. As this is rendered as a table, it looses the ability to float. So you have to set a width explicitly on at least one of the elements.
CSS
div {
display: table-cell;
vertical-align: middle;
}
div:first-child {
width: 80%;
}
HTML
<div>
first line<br>
second line<br>
last line
</div>
<div>
just one line<br>
</div>
Fiddle
http://jsfiddle.net/y96hb/