admin管理员组文章数量:1320637
joomla 5 module for vertical menu.
$max_width
is a php code that get width for the menu by the module admin panel.
this mean : if i set the width of the menu to 300px in admin panel ,
then $max_width
will output 300px on the site .
this is my php code :
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.'); margin-right: '.$max_width.' ; }';
?>
this code will resize the element #sp-main-body to be -300px .
my question is :
how can i add 10px to $max_width or take 10px from #sp-main-body ?
i try this :
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.' - 10px); margin-right: '.$max_width.' ; }';
?>
and this :
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.'); margin-right: '.$max_width.' ; +10px }';
?>
but it is not working !!
joomla 5 module for vertical menu.
$max_width
is a php code that get width for the menu by the module admin panel.
this mean : if i set the width of the menu to 300px in admin panel ,
then $max_width
will output 300px on the site .
this is my php code :
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.'); margin-right: '.$max_width.' ; }';
?>
this code will resize the element #sp-main-body to be -300px .
my question is :
how can i add 10px to $max_width or take 10px from #sp-main-body ?
i try this :
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.' - 10px); margin-right: '.$max_width.' ; }';
?>
and this :
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.'); margin-right: '.$max_width.' ; +10px }';
?>
but it is not working !!
Share Improve this question asked Jan 18 at 12:04 user28928120user28928120 431 silver badge4 bronze badges 3 |1 Answer
Reset to default 1To add 10px or subtract 10px in your calculation, you need to ensure that your syntax is correct in the CSS calc() function and also properly concatenate the strings in PHP. Here's how you can modify your PHP code to achieve this:
Adding 10px to $max_width in calc():
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.' + 10px); margin-right: calc('.$max_width.' + 10px); }';
?>
Subtracting 10px from $max_width in calc():
<?php
$custom_css .= '#sp-main-body {width: calc(100% - '.$max_width.' - 10px); margin-right: calc('.$max_width.' - 10px); }';
?>
May be you can try this one, not sure but hope this works!
本文标签: csshow to add number of px to this element in phpStack Overflow
版权声明:本文标题:css - how to add number of px to this element in php? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742073915a2419292.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
calc(calc(100%-300px)-10px)
. – Markus Zeller Commented Jan 18 at 12:16$max_width
, i need it because i set the width in admin panel . – user28928120 Commented Jan 18 at 13:09