1

i have a case in which the two values of the following should be changing according to the data in database. In a external css file i have this.

#wow-container1 { 
    zoom: 1; 
    position: relative;
    width: 100%;
    max-width:960px;
    max-height:360px;
    margin:0px auto 0px;
    z-index:90;
    border:2px solid #FFFFFF;
    text-align:left; 
    font-size: 10px;
}

my requirement is i need to change the max-height:max-width: when the height and width stored in database is changed.Is there any possible solution.?

3
  • 1
    You could reconfigure your php.ini file to allow PHP to interpret it into your CSS document (allow PHP in non .php files). That, or you could use LESS or SASS. Your call. Commented Feb 20, 2017 at 5:42
  • You can do it easily using javscript or jquery. Commented Feb 20, 2017 at 5:44
  • You could aso use JavaScript and completely forget about the CSS in the file. Commented Feb 20, 2017 at 5:44

4 Answers 4

2

Try this using jQuery .css()

var width = "value from DB";
var height = "value from DB";
$('#wow-container1').css({ 'max-width' : width, 'max-height' : height });
Sign up to request clarification or add additional context in comments.

Comments

0

you can get max-height,max-width from db, Example in php:

<?php
    $max_height='300px';//you have to get the value form db
    $max_width='300px'; //you have to get the value form db
?>

then write beloved css part after calling your external css file

<style>
#wow-container1 { 
  max-width:<?php echo $max_width; ?>;
  max-height:<?php echo $max_height; ?>;

}
</style>

You can do it in your programming language.

Comments

0

.css() jquery is the best solution for this. If you want to change it using css, you have to put database value in inline css written in same page. like this :

<style>
#wow-container1 { 
  max-width:<?php echo $width; ?>;
  max-height:<?php echo $height; ?>;

}
</style>


If you want to use jquery .css(), it will be like this :


var width = "width from database";
var height = "height from database";
$('#wow-container1').css({ 'max-width' : width, 'max-height' : height });

Comments

0

When you learn http://VueJS.org you can use 'v-blind' to do that, very simple!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.