Hi there and thanks in advance,
NOTE: The site is NSFW, just some ebooks for adults (romance and that stuff, but the ebooks covers may be hot).
My environment:
I have WP with a woocommerce, storefront+bookshop child theme
I have the Snippets plugins where I add all my PHP code
And I add CSS to Custom CSS within customizer
Now the problem:
I can´t figure out how to make site header, top nav bar and logo + buttons responsive.
The fact is that I could get some Top header styling using some PHP and CSS, BUT when I go to mobile view, the Top nav var, header, logo and menu goes crazy!
I need to fix that, I don´t know what to try (I googled a lot, tried changing values, %, float, inline, block, important, whatever) but I can´t get the right tip.
I don{t know if the child theme or storefront itself is overriding my attempts, maybe I have to unhook some function.
Maybe is just as simple as putting all 3 PHP snippets into one div and many spans tag, but I can´t figure out how I am burnt today.
I would thank any advice.
Here goes my CSS
/* Logo size for mobile site */
#media screen and (max-width: 768px) {
.site-header .site-branding img {
max-height: none !important;
max-width: none !important;
width: 322px !important;
}
}
/*Remove title from Shop page*/
.woocommerce-products-header
{display: none;}
/*Hide Pages Tite with custom Class added to PHP snippets*/
.hidetitle .entry-header {
display:none;
}
/*Make primary Pages full width*/
body.woocommerce #primary {
width: 100%;
}
/*Align Search Bar and make text pink*/
#woocommerce-product-search-field-0 {
display:inline-block;
width:100%;
color: #fe00a1;
border: solid 1px #fe00a1;
}
/*Edited Cart*/
#site-header-cart{
padding-bottom:20px;
width:15%;
}
/*Changed cart icon bag f\290 to to cart icon f\217 */
.site-header-cart .cart-contents:after,
.storefront-handheld-footer-bar ul li.cart > a:before {
content: “\f217”;
}
/*Align Help link*/
#help{
display:inline-block;
padding-left: 35px;
padding-right: 35px;
}
/*Align Gift card*/
#gift-cardl{
margin-left:80px;
}
/*Add top padding to rectangle*/
#rectangle {
padding:17px;
}
**PHP snippets**
add_action( ‘storefront_header’, ‘header_custom_gift_button’, 40 );
function header_custom_gift_button() { ?>
<span>
<button id=”gift-cardl”>Gift Card</button>
</span>
<?php
}
add_action( ‘storefront_header’, ‘header_custom_help_link’, 40 );
function header_custom_help_link() { ?>
<span style=”width:100%;”>
Help
</span>
<?php
}
add_action( ‘storefront_header’, ‘header_custom_subscribe_button’, 40 );
function header_custom_subscribe_button() { ?>
<button class=”subscribe_newsletter_btn”>Get Daily Book Bargains</button>
</span>
<?php
}
Related
I am trying to build a custom template from scratch for my Joomla 3.9 website. I am new to web design. I have been following several tutorials on how to set up menu style via CSS, but I cannot seem to find information on how to define the drop-down menu style. The menu items are defined in Joomla configuration, and the menu should be injected into the right place.
relevant lines from index.php:
<body>
<div class="nav">
<nav>
<jdoc:include type="modules" name="navigation" style="none"/>
</nav>
</div>
</body>
And from template.css:
.nav {
background-color:#FFA500;
position: sticky;
top: 0;
}
ul.nav { //this element needs centering
margin:auto;
width:80%;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #FFA500;
}
ul.nav li {
float:left;
display:block;;
text-align: center;
padding: 14px 16px;
text-decoration: none;
border-right: 3px solid #bbb;
}
ul.nav li:last-child {
border-right: none;
}
ul.nav li a{
color: white;
font-size: 20px
}
ul.nav li:hover {
background-color: #e09100;
}
This code works fine for displaying the menu the way I want (except for not centering it in the screen, but that's not relevant) for simple menu items. However, if I add sub-menu items in Joomla Menu configuration, it gets all messed up. I want these sub-menus to be displayed in a drop-down fashion when the user hovers over the parent item with the mouse, but instead, right now these sub-menus are displayed below the parent item statically. Obviously, that's because I haven't written the code for that part yet.
Problem is, I do not know how to define the style for these sub-menu items, because they are not defined in the CSS, but instead, provided by Joomla. I cannot find any relevant documentation that would tell me the keywords to hook up to these items. Can someone tell me how to turn these sub-menu items into a nice drop-down menu when the user hovers the mouse over the parent menu item?
so I am still quite new to wordpress development so don't rage and I am sorry if I did something really stupid.
So I am having trouble with my CSS, for some reason it's not affecting the widget content output, which can be seen in the movieposterdisplay-class file. What I am trying to do is make the outputted youtube video auto size to fit the container using CSS. What I want to know is why the CSS isn't affecting the HTML code and a solution to fix it.
So far I tried using !important in case the wordpress theme was overriding the CSS but the problem must be related to something else. Thanks in advance for any help.
movieposterdisplayfile
require_once(plugin_dir_path(__FILE__).'/includes/movieposterdisplay-
scripts.php');
require_once(plugin_dir_path(__FILE__).'/includes/movieposterdisplay-
class.php');
function register_movieposterdisplay(){
register_widget('Movie_Poster_Display_Widget');
}
add_action('widgets_init', 'register_movieposterdisplay');
movieposterdisplay-scripts file
<?php
function mpd_add_scripts(){
wp_enqueue_style('mpd-main-style', plugins_url().'/movieposterdisplay/css/style.css');
wp_enqueue_script('mpd-main-style', plugins_url().'/movieposterdisplay/js/main.js');
}
add_action('wp_enqueue_scripts', 'mpd_add_scripts');
movieposterdisplay-class file (file contains the widget output)
<?php
class Movie_Poster_Display_Widget extends WP_Widget {
function __construct() {
parent::__construct(
'movieposterdisplay_widget', // Base ID
esc_html__( 'Movie Widget', 'mpd_domain' ), // Name
array( 'description' => esc_html__( 'Displays Movie/TV posters, overviews and trailers.', 'mpd_domain' ), )
);
}
public function widget( $args, $instance) {
echo $args['before_widget'];
$trailer_key ="http://www.youtube.com/embed/" .$this->display_trailer($instance, $first_movie_result)."?enablejsapi=1";
?>
<div class="youtubeplayer">
<iframe
id="player" type="text/html"
src="<?php echo $trailer_key;?>"
frameborder="0" allowfullscreen="allowfullscreen">
</iframe>
</div>
<?php
echo $args['after_widget'];
}
style.css
.youtubeplayer {
position: relative !important;
padding-bottom: 75% !important;
padding-top: 25px !important;
height: 0 !important;
border: 5px solid red !important;
}
.youtubeplayer iframe {
position: absolute !important;
top: 0 !important;
left: 0 !important;
width: 100% !important;
height: 100% !important;
}
The problem was due to an incorrect file path in the movieposterdisplay-scripts file. Whilst the file loaded correctly in the main php file
require_once(plugin_dir_path(__FILE__).'/includes/movieposterdisplay- class.php');
as it already assigned the correct plugin folder name. It did not enqueue correctly as the code was wp_enqueue_style('mpd-main-style', plugins_url().'/movieposterdisplay/css/style.css'); and I had previously changed the folder name.
Hence I thought it was loading correctly and running fine, however it was only loading correctly.
WordPress|storefront|woo-commerce.
i am trying to display header on desktop view and footer on mobile responsive for specific page id 1.but even using specific page id both classes shows on page id 1 header,footer.Tried both id and class with cascading rule of hierarchy.Here id abc displays on page id 1 desktop view and abcd on page id 1 mobile.
My code for child function.php is
add_action( 'storefront_header', 'header_content1', 30 );
function header_content1() { ?>
<div id/class="abc" > my text with css</div><?php
}
add_action( 'storefront_after_footer', 'header_content2', 10 );
function header_content2() { ?>
<div id/class="abcd" > my text with css</div><?php
}
CSS child theme.
.page-id-1 .abc {
text-align: right;
padding-top: 0.02em;
color: #0000ff;
}
.abc{
display:none!important;
}
.abcd{
display:none!important;
}
.page-id-1 .abcd{
display:none!important;
visibility:hidden;
}
#media only screen and (max-width: 599px){
.abc{
display:none!important;
}
.abcd{
display:none!important;
}
.page-id-1 .abc{
display:none !important;
visibility:hidden;
}
.page-id-1 .abcd {
display:block !important;
text-align: center;
padding-top: 0.02em;
color: #0000ff;
}
}
A better approach would be to only load your function on the page that is needed instead of hidding your HTML in all pages but one...
You can check the page ID before running the function with something like this:
if (is_page('1') {
add_action( 'storefront_header', 'header_content1', 30 );
function header_content1() { ?>
<div id/class="abc" > my text with css</div><?php
}
}
Here is my website's mobile version
I want to add small text 'MENU' here
When I try to add here it is visible in desktop version too.
<div id="responsive-menu-container">
<span class="menu">MENU</span>
</div>
How to add this text in mobile version only?
Or maybe not the code, but the way I try to add is incorrect?
You can hide or show it with #media tags with css. Like this:
Your normal css class:
.menu{
display:none;
}
Your mobile version class:
#media only screen and (max-width: 767px) {
.menu{
display:block;
}
}
After that by using your example, you have to put "menu" span inside your "responsive-menu-container". After adding it, you can adjust its position.
<div id="responsive-menu-container">
<span class="menu">MENU</span>
</div>
Edit for position:absolute :
If you are using a reference library for menu bar and creating this content with automatically, you can also use position:absolute for .menu class. Like this:
#media only screen and (max-width: 767px)
.menu {
display:block;
position: absolute;
z-index: 9999999; /* I gave this value because your menu bar's z-index must be smaller than this. */
margin-top: 15px;
margin-left: 15px;
}
I'm building a stock photo site and it is (I think) good to show only pictures on the shops home page.
I figured out how to hide the Titles, Prices and Buttons (with remove_action) in my twentytwelve child theme (functions.php)
Now on adding masonry. I added a bit of code (a snippet from James Koster) to enqueue the WP build in Masonry script.
add_action( 'wp_enqueue_scripts', 'jk_masonry' );
function jk_masonry() {
wp_enqueue_script( 'jquery-masonry', array( 'jquery' ) );
}
I added the following code to my footer.php and I can see in the markup that it is loaded.
<script>
jQuery(document).ready(function($) {
$('#content').masonry({
itemSelector: 'products',
isAnimated: true;
});
});
</script>
No changes on my page.
I added this to my child theme styl.css:
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product,
#primary ul.products li.product{
margin-right: 3px;
margin-bottom: 3px;
}
Sadly, no effect on my page. No Masonry effects, no changes in the margins of the items. See screenshot.
The question is: were to go from here. I've searched the internet, found several possibilities but it seems to be that I don't understand it. (newbie) I'm looking for a result as shown here: lhotse masonry.
EDIT: html output
<div id="primary" class="site-content"><div id="content" role="main">
<div class="page-description"><div class="post-text"></div>
<p> </p>
</div>
<ul class="products">
<li class="post-70 product type-product status-publish has-post-thumbnail first sale taxable shipping-taxable purchasable product-type-simple product-cat-posters product-tag-adri instock">
<a href="http://localhost/shop/flying-ninja/">
<img width="600" height="600" src="http://localhost/wp-content/uploads/2013/06/poster_2_up-600x600.jpg" class="attachment-shop_catalog wp-post-image" alt="poster_2_up" />
</a>
</li>
<!-- Following items-->
</ul>
END EDIT
EDIT NR. 2
Yesterday I learned a method to override the standard woocommerce css files. If curious... throw me a line. However in the case of my problem it is only a bit of the solution. As formerly stated I want to use masonry on my woocommerce shoppage. The way it works looks like this:
As you can see there are 4 columns to fill the total widht of the surrounding div. However Masonry did not kicked in. When I resize my browser window to a smaller size the images are not resizing. (responsive) till a certain screen width. Then suddenly the layout changes to a 3 column layout and masonry kickes in. See screenshot.
The change to 3-columns must have something to do with css.... however I can't figure out what. Silly me.
Then when resizing the screen further (smaller) The layout went to two columns (that's understandable) but masonry stops working. See screenshot.
I did expect a working masonry and responsive layout.
END EDIT 2
Im totally stucked here.
Any help is very, very much appreciated. Thanks in advance.
At first I needed to override the standard woocommerce css behavior. As mevius suggested in the comments above this was a possibility. So I dequeued the styles, copied the files into my /childtheme/woocommerce/css folder en enqueued them on this new location. This way when an update is coming out the css files are not overwritten. Here is the code for the functions.php of my child theme:
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] ); // Remove the gloss
unset( $enqueue_styles['woocommerce-layout'] ); // Remove the layout
unset( $enqueue_styles['woocommerce-smallscreen'] ); // Remove the smallscreen optimisation
return $enqueue_styles;
}
function wp_enqueue_woocommerce_style(){
wp_register_style( 'woocommerce-layout', get_stylesheet_directory_uri() . '/woocommerce/css/woocommerce-layout.css' );
if ( class_exists( 'woocommerce' ) ) {
wp_enqueue_style( 'woocommerce-layout' );
}
wp_register_style( 'woocommerce-smallscreen', get_stylesheet_directory_uri() . '/woocommerce/css/woocommerce-smallscreen.css' ,array(),'4.0.1','only screen and (max-width: 768px)' );
if ( class_exists( 'woocommerce' ) ) {
wp_enqueue_style( 'woocommerce-smallscreen' );
}
wp_register_style( 'woocommerce-general', get_stylesheet_directory_uri() . '/woocommerce/css/woocommerce.css' );
if ( class_exists( 'woocommerce' ) ) {
wp_enqueue_style( 'woocommerce-general' );
}
}
To get masonry working I added the following to my functions.php just above the dequeueing and enqueuing of the woocommerce style sheets.
add_action( 'wp_enqueue_scripts', 'jk_masonry' );
function jk_masonry() {
wp_enqueue_script( 'jquery-masonry', array( 'jquery' ) );
}
and I put this code in my child themes footer.php:
<script>
jQuery(document).ready(function($) {
$('.products').masonry({
itemSelector: '.product',
isAnimated: true
});
});
</script>
Next I had to change some styles in the woocommerce css files.
I changed the rules below to: (just perform a search in your css files)
In woocommerce.css:
.woocommerce .products ul li,
.woocommerce ul.products li,
.woocommerce-page .products ul li,
.woocommerce-page ul.products li {
list-style: none;
width: 24.3%;
margin-right: 8px;
margin-bottom: 8px;
}
.woocommerce ul.products li.product a img,
.woocommerce-page ul.products li.product a img {
width: 100%;
height: auto;
display: block;
-webkit-transition: all ease-in-out .2s;
-moz-transition: all ease-in-out .2s;
-o-transition: all ease-in-out .2s;
transition: all ease-in-out .2s;
}
Some of the above ar just cosmetic.
In the woocommerce-layout.css file:
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
float: left;
margin: 0 8px 8px 0;
padding: 0;
position: relative;
width: 24.5%;
}
and in the woocommerce-smallscreen.css :
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
width: 48%;
float: left;
clear: both;
margin: 0 2px 2px 0;
}
#media screen and (max-width: 450px) {
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
width: 100%;
float: left;
clear: both;
margin: 0 0 2px 0;
}
}
As far as I can tell works this quite good. Responsivness is ok. Even the images are animating to their new positions when resizing the screen. Good luck with it.