DIV won't show up over a DIV that's underneath it - css

I can't figure out how to get a DIV to show up over a DIV that's underneath it. In other words, my webpage has a head, with a DIV that floats left and a DIV that floats right. Underneath that is a menu bar. I don't have many menu items, so I want image in the DIV that floats right to partially overlap the menu bar. I'm able to make it work with absolute positioning... but that not ideal. I went ahead and changed the width of the menu bar, but that's more of a temporary fix to get what I want. Thoughts?
www.sacspartans.org
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<div id="header-left">
<hgroup>
<h1 class="site-title">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<img src="http://sacspartans.org/wp-
content/uploads/2013/05/banner.png" alt="SacSpartans"
title="SacSpartans" border="0" />
</a>
</h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?>
</h2>
</hgroup>
</div>
<div id="header-right">
<img src="http://sacspartans.org/wp-
content/uploads/2013/05/california1.png" alt="MSU Alumni Club of
the Sacramento Valley" title="MSU Alumni Club of the Sacramento
Valley" border="0" />
</div>
<div id="navigation-bar">
<nav id="site-navigation" class="main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
<a class="assistive-text" href="#content" title="<?php esc_attr_e(
'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to
content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary',
'menu_class' => 'nav-menu' ) ); ?>
</nav>
</div>
And now CSS info.
/* Header */
#header-left {
float: left;
}
#header-right {
float: right;
margin-top: 0;
}
#navigation-bar {
width: 575px;
}

Related

I can't add margin to position sticky in WordPress site

I want to move left-sidebar which contains sticky top to below because it below to main header while down scrolling.
However, I cant add margin top to sticky-top under col-sm-1.
<style>
.col-sm-1 .sticky-top { margin-top: 50px}
</style>
50px is not important.The lenght should be enough to move the div to below header.
the page's codes:
<?php get_header(); ?>
<div class="container-fluid">
<!-- Control the column width, and how they should appear on different devices -->
<div class="row">
<div class="col-sm-10" >50%
<main role="main">
<!-- section -->
<section>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>
<!-- <a href="<?php //the_permalink(); ?>" title="<?php //the_title(); ?>"> -->
<?php the_post_thumbnail(); // Fullsize image for the single post ?>
</a>
<?php endif; ?>
<!-- /post thumbnail -->
<!-- post title -->
<h1>
<!-- <?php //the_title(); ?>-->
</h1>
<!-- /post title -->
<div class="row">
<div class="col-sm-1 " >50%
<?php global $post; ?>
<style>
.logo-img2{
border: 1px solid #d0d0ff;padding:20px; margin-top: 0px; margin-bottom: 0px;
}
</style>
<style>
.col-sm-1 .sticky-top { margin-top: 50px}
</style>
<div class="sticky-top ">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo get_permalink($post->ID);?>">
<div>
<img src="<?php echo get_template_directory_uri(); ?>/img/icons/facebook.png" alt="Logo" class="logo-img2"">
</div>
</a>
<a href="https://twitter.com/share?url=<?php echo get_permalink($post->ID);?>">
<div>
<img src="<?php echo get_template_directory_uri(); ?>/img/icons/twitter.png" alt="Logo" class="logo-img2"">
</div>
</a>
<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?>">
<div>
<img src="<?php echo get_template_directory_uri(); ?>/img/icons/pinterest.png" alt="Logo" class="logo-img2" >
</div>
</a>
<div class=" logo-img2" style="padding: 0px; text-align: center">
<ul class="list-inline">
<li class="list-inline-item">
Tooltip
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-11" >
<!-- post details -->
<span class="date"><?php the_time('F j, Y'); ?> <?php the_time('g:i a'); ?></span>
<span class="author"><?php _e( 'Published by', 'html5blank' ); ?> <?php the_author_posts_link(); ?></span>
<span class="comments"><?php if (comments_open( get_the_ID() ) ) comments_popup_link( __( 'Leave your thoughts', 'html5blank' ), __( '1 Comment', 'html5blank' ), __( '% Comments', 'html5blank' )); ?></span>
<!-- /post details -->
<?php the_content(); // Dynamic Content ?>
<?php the_tags( __( 'Tags: ', 'html5blank' ), ', ', '<br>'); // Separated by commas with a line break at the end ?>
<p><?php _e( 'Categorised in: ', 'html5blank' ); the_category(', '); // Separated by commas ?></p>
<p><?php _e( 'This post was written by ', 'html5blank' ); the_author(); ?></p>
<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
<?php comments_template(); ?>
</div>
</article>
<!-- /article -->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h1><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h1>
</article>
<!-- /article -->
<?php endif; ?>
</section>
<!-- /section -->
</main>
</div>
<div class="col-md-2" style="background-color:orange;height: 100%; width: 100%;">50%
<?php get_sidebar(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
There are some undeleted lines which is showed with <!-- so sorry.
The link : http://www.themeforest-deneme2.deniz-tasarim.site/2020/01/10/yazi-9/
Welcome to SO!
As you have position sticky so you need top value to move it like in your case set top: 60px rather then margin
.col-sm-1 .sticky-top {
/* margin-top: 50px; */
top: 60px;
}
The main difference between static or relative and absolute or fixed
was the space they take up in the flow of the DOM. Positions static &
relative keep their natural space in the flow of the document, while
the absolute & fixed don’t — their space is removed and they have a
floating behavior.
Reference for more understanding
Also its bad to use default frame-work classes to target any class/ make it selector

Changing Logo based on pages in WordPress

I'm trying to change the header logo on my site, depending on the page the person is on. I don't know PHP, but I've found where the Logo is defined in header.php, and am trying to rewrite it to be dynamic. When I use my code, the site breaks, so obviously I'm doing something wrong.
Here is the code of my header.php file.
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head><meta charset="<?php bloginfo( 'charset' ); ?>">
<!-- Set the viewport width to device width for mobile -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css" integrity="sha256-0LjJurLJoa1jcHaRwMDnX2EQ8VpgpUMFT/4i+TEtLyc=" crossorigin="anonymous" />
<?php
wp_head();
?>
<style>
.chosen-container .chosen-results {
height: 100%;
overflow-y: hidden;
max-height: inherit;
}
.chosen-container-active .chosen-single, .chosen-container-single .chosen-single {
display: none;
}
.chosen-container-single .chosen-drop {
display: contents;
}
</style>
</head>
<body <?php body_class(); ?>>
<div class="<?php $themnific_redux = get_option( 'themnific_redux' );
if (empty($themnific_redux['tmnf-uppercase'])) {} else {if($themnific_redux['tmnf-uppercase'] == '1') echo 'upper '; }
if (empty($themnific_redux['tmnf-bottombar-dis'])) {} else {if($themnific_redux['tmnf-bottombar-dis'] == '1') echo 'bottombar_dis '; }
if ( is_active_sidebar( 'tmnf-sidebar' ) ) {echo 'tmnf-sidebar-active ';} else { echo 'postbarNone ';};
if (empty($themnific_redux['tmnf-header-layout'])) {} else {echo esc_attr($themnific_redux['tmnf-header-layout']);}
?>">
<div id="header" class="tranz" itemscope itemtype="http://schema.org/WPHeader">
<div class="container_head">
<a class="screen-reader-text ribbon skip-link" href="#content_start"><?php esc_html_e('Skip to content','citygov');?></a>
<div class="clearfix"></div>
<div id="titles" class="tranz2">
<?php if(empty($themnific_redux['tmnf-main-logo']['url'])) { ?>
<h1 class="logo"><?php bloginfo('name');?></h1>
<?php }
else { ?>
<a class="logo" href="<?php echo esc_url(home_url('/')); ?>">
<img class="tranz" src="<?php echo esc_url($themnific_redux['tmnf-main-logo']['url']);?>" alt="<?php bloginfo('name'); ?>"/>
</a>
<?php } ?>
</div><!-- end #titles -->
<div class="header-right for-menu">
<input type="checkbox" id="showmenu" aria-label="<?php esc_html_e('Open Menu','citygov');?>">
<label for="showmenu" class="show-menu ribbon" tabindex="0"><i class="fas fa-bars"></i> <span><?php esc_html_e('Menu','citygov');?></span></label>
<nav id="navigation" class="rad tranz" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation" aria-label="<?php esc_html_e( 'Main Menu', 'citygov' ); ?>">
<?php get_template_part('/includes/navigation'); ?>
</nav>
</div><!-- end .header-right -->
<div class="clearfix"></div>
<div id="bottombar" class="bottomnav tranz" role="navigation" aria-label="<?php esc_html_e( 'Quick Links', 'citygov' ); ?>">
<?php if(empty($themnific_redux['tmnf-menu-label'])) {} else { ?>
<p class="menu_label"><?php echo esc_attr($themnific_redux['tmnf-menu-label']); ?></p>
<?php }?>
<div class="header-right">
<?php get_template_part('/includes/add-navigation'); ?>
<?php get_template_part('/includes/uni-social' );?>
</div>
</div><!-- end #bottombar -->
<div class="clearfix"></div>
</div><!-- end .container -->
</div><!-- end #header -->
<?php ?>
<div class="wrapper p-border">
You can do this by simply put below code in your theme's functions.php file.
after putting this code, you can now see the new settings added into back-end admin area.
Go to the wordpress admin area then go to Appearance > Customize > Site Identity.
You can now see there are two new settings.
1)Upload Logo (replaces text) => You can add second logo for other pages
2) Page IDs. => You can add comma separated page ids in this text box for displaying second logo in that pages.
function jay_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'jay_logo' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'jay_logo', array(
'label' => __( 'Upload Logo (replaces text)', 'jay' ),
'section' => 'title_tagline',
'settings' => 'jay_logo',
) ) );
$wp_customize->add_setting('page_ids');
$wp_customize->add_control('text_setting', array(
'label' => 'Page IDs',
'section' => 'title_tagline',
'type' => 'text',
'settings' => 'page_ids',
));
}
add_action( 'customize_register', 'jay_customize_register' );
function change_logo_on_single($html) {
$pageIDs = (get_theme_mod('page_ids'))? explode(',',get_theme_mod('page_ids')) : array();
if(in_array(get_the_ID(),$pageIDs)){
$html = preg_replace('/<img(.*?)\/>/', '<img src="'.get_theme_mod('jay_logo').'" class="custom-logo" alt="" itemprop="logo" />', $html);
}
return $html;
}
add_filter('get_custom_logo','change_logo_on_single');

Sidebar area not floating correctly

I am trying to get a sidebar to appear correctly in Wordpress framework with some effort here but I am almost their but the sidebar needs to appear to the right of the text of the blog just beside the title to the far right
You can view the page in question here http://kvalixhu.digitalthinkersni.co.uk/blog/
Image for how I want it to display
https://nimbus.everhelper.me/client/notes/share/369625/9zqAVkxFA4iFRBTqA1E5mw20uuWOqgs8/
<?php
/**
* Template Name: BlogPosts
*/
get_header();
?>
<style>
#title_wrapper{
width:488px;
}
h2{
font-size:18px;
font-familly:verdana, arial, sans-serif;
line-height:16px;
display:inline;
padding:2px;
}
#dateinfo{
font-weight:bold;
}
</style>
<div id="main-content" class="main-content">
<?php
if (is_front_page()) {
get_template_part('featured-content');
}
?>
<div class="full-width page-header">
<div class="row">
<div class="column">
<h1>Blog</h1>
</div>
</div>
</div>
<div class="row show-for-medium-up">
<div class="column breadcrumb">
<?php
if (function_exists('yoast_breadcrumb')) {
//echo __('Home',TD) . ' > ';
yoast_breadcrumb('<span id="breadcrumbs">', '</span>');
}
?>
<?php
if (function_exists('bcn_display_list_multidim_children')) {
?><ul class="breadcrumbs">
<?php
bcn_display_list_multidim_children();
?>
</ul><?php
}
?>
</div>
</div>
<div class="row">
<div class="column small-12 product">
<?php
$logo = get_post_meta(get_the_ID(), 'logo', true);
?>
<div class="post-list" style="width:80%;">
<?php
$myposts = get_posts('numberposts=-1&offset=$debut');
foreach ($myposts as $post):
setup_postdata($post);
?>
<div id="dateInfo" style="float:right;">
<?php the_date('Y.m.j'); ?> |
<?php comments_number( '0 hozzászólás', '1 hozzászólás', '% hozzászólás' ); ?>.
</div>
<div id="title_wrapper">
<h2><?php the_title(); ?></h2>
</div>
<div class="thumbnail" style="float: left; margin: 10px">
<?php the_post_thumbnail( array( 395, 195 ) ); ?>
<div class="thumbnail-arrow"></div>
</div>
<!-- Display movie review contents -->
<div class="entry-content"><?php the_content(); ?></div>
<div>
<?php
endforeach;
?>
<div class="column small-6 product " style="float:right;">
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Right Sidebar')) : ?>
[ do default stuff if no widgets ]
<?php endif; ?>
</div>
<hr />
</div>
</div> </div>
</div>
<?php
get_footer();
?>
The first thing that you would want to do is move the "sidebar div" outside of the post-list div, and adding "float:left;" to the post-list div.
Also, add a width to the sidebar div with "width: 20%;" to make sure it fits.
The answer is a bit vague but hopefully you understand.
Hopefully this helps

WP: problems with qTranslate styles

I am using the plugin qTranslate 2.5.39 and wordpress 3.8.1.
I want to have a drop down with the flags in the header and as the FAQ points, here is my header.php code:
<div id="navbar" class="navbar">
<nav id="site-navigation" class="navigation main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></h3>
<a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
<!--<?php get_search_form(); ?>-->
<?php qtrans_generateLanguageSelectCode('image'); ?>
</nav><!-- #site-navigation -->
</div><!-- #navbar -->
And in my styles.css
.qtrans_language_chooser { list-style-type:none; background-color: red }
.qtrans_language_chooser li { float:left; margin-right:3px }
.qtrans_flag { border:1px solid #b6b6b6 }
I tried as well with !important, but didnt work.
The source code:
<ul class="qtrans_language_chooser" id="qtranslate-chooser">
<li class="lang-de">
<a href="http://link/?lang=de" hreflang="de" title="Deutsch" class="qtrans_flag qtrans_flag_de">
<span style="display:none">Deutsch</span>
</a>
</li>
<li class="lang-en">
<a href="http://myfavcolorismusi.byethost32.com/immtranslates/?lang=en" hreflang="en" title="English" class="qtrans_flag qtrans_flag_en">
<span style="display:none">English</span>
</a>
</li>
<li class="lang-es active">ç
<a href="http://myfavcolorismusi.byethost32.com/immtranslates/" hreflang="es" title="Español" class="qtrans_flag qtrans_flag_es">
<span style="display:none">Español</span>
</a>
</li>
</ul><div class="qtrans_widget_end"></div>
Any ideas? Thanks
EDIT
Could it be a google chrome style managment problem?
in css file of your theme, try
#qtranslate-chooser{//style}
#qtranslate-chooser li{//style}
...

Aligning header elements (text / logo / nav) within a div

Okay, so will confess to being completely new at this. I am a designer, first and foremost and trying to learn how to code by dismantling pre-built templates and studying them.
What I want to do is - have a short line of text (left float), a centered logo (whose width / height may vary upon finalization), and a text nav (right float). I am modifying a theme.
Here is what I have:
<header id="header" class="wrapper<?php if (get_option($prefix.'_width') == "width_full") { ?>_full<?php } ?>">
<div class="header_top clearfix">
<div id="logo" class="left_float">
<a class="logotype" href="index.php"><img src="<?php echo get_option($prefix.'_logo', 'images/logo.png'); ?>" alt="Logotype"></a>
</div>
<?php if(function_exists('wp_nav_menu')) : ?>
<?php
wp_nav_menu(
array(
'theme_location' => 'primary-menu',
'container' => 'nav',
'container_id' => 'nav',
'container_class' => 'right_float',
'menu_class' => '',
'menu_id' => '' ,
'walker' => new custom_menu_output()
));
?>
<?php else: ?>
<nav id="nav" class="right_float">
<ul>
<?php wp_list_pages('title_li=&depth=0'); ?>
</ul>
</nav>
<?php endif; ?>
</div>
Below is the CSS. I've tried to interchange the .left_float with the .center class as a test, but it ends up pushing the nav downwards.
.left_float {
float: left;
}
.center {
display: block;
margin-left: auto;
margin-right: auto }
.right_float {
float: right;
}
Long post - sorry! Any help would be appreciated - even some links where I can read and learn and get started on my own.
Thanks a bunch!
Part 1: First of all, there is no <div> with class center in your code. Start off by putting all of your code that's between the left_float and right_float <div> tags into its own <div class="center">...</div> tag. I'm assuming you want something like:
<header id="header" class="wrapper<?php if (get_option($prefix.'_width') == "width_full") { ?>_full<?php } ?>">
<div class="header_top clearfix">
<div id="logo" class="left_float">
<a class="logotype" href="index.php"><img src="<?php echo get_option($prefix.'_logo', 'images/logo.png'); ?>" alt="Logotype"></a>
</div>
<div class="center">
<?php if(function_exists('wp_nav_menu')) : ?>
<?php
wp_nav_menu(
array(
'theme_location' => 'primary-menu',
'container' => 'nav',
'container_id' => 'nav',
'container_class' => 'right_float',
'menu_class' => '',
'menu_id' => '' ,
'walker' => new custom_menu_output()
));
?>
<?php else: ?>
</div>
<nav id="nav" class="right_float">
<ul>
<?php wp_list_pages('title_li=&depth=0'); ?>
</ul>
</nav>
<?php endif; ?>
</div>
<br clear="all" />
You'll notice I added <div class="center">...</div> and added <br clear="all" /> (which is important for the next part...)
Part 2: Change your CSS to:
.left_float, .center, .right_float {
float: left;
}
But make sure you keep the new <br clear="all" /> in your code! With that at the end, you can float all divs to the left, and they will all be beside each other. From there, you can modify the width of each of the divs to whatever you'd like!
Well, I hope that helps,
Hope4You
Your wp_nav_menu is without any div. Enclose is withing a div and add just a single class class=lfloat to all the three divs.
`.lfloat{
float: left;
}`

Resources