/ / Wordpress Redux Framework Media Queries - PHP, CSS, WordPress, Redux-Framework

Wordpress Redux Framework Media Abfragen - PHP, CSS, WordPress, Redux-Framework

Ich habe mich umgesehen und noch keine Antworten gefunden. Meine Fragen sind:

  1. Wie kann man dynamisches CSS in Medienabfragen ausgeben? Meiner Meinung nach wurde die CSS-Ausgabe von WordPress Redux-Framework global geschrieben (sowohl im Compiler- als auch im Inline-Stil) und wirkt sich auf alle Bildschirmgrößen aus.

  2. Was ist der einfachere Weg, um dynamisches CSS im Redux-Framework in Medienabfragen auszugeben?

Antworten:

0 für die Antwort № 1

Habe das nicht getestet, sollte aber einen groben Einstieg ermöglichen. Sie können mehrere Felder verwenden (z. B. für 480, 768, 991 usw.) und den Code einfach mit wp_add_inline_style ausgeben.

function my_custom_css(){

//get the theme option
$option = get_option("opt_name");

// get the fields holding the custom css for each media query
$media_991_css = $option["css991"];
$media_768_css = $option["css768"];
$media_480_css = $option["css480"];

// store the values in a variable
$output  = "@media screen and (max-width: 991px){" . $media_991_css . "}";
$output .= "@media screen and (max-width: 768px){" . $media_768_css . "}";
$output .= "@media screen and (max-width: 480px){" . $media_480_css . "}";

// output it with wp_add_inline_style
if(!empty($output)){
wp_add_inline_style("style",$output);
}
}

add_action("wp_enqueue_scripts","my_custom_css");

Sie müssten natürlich eine ordnungsgemäße Flucht sicherstellen, aber dies sollte Ihnen das bringen, was Sie brauchen.