Vimal
Vimal

Reputation: 1146

Getting a variable inside a external css file

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.?

Upvotes: 1

Views: 659

Answers (4)

cuduy197
cuduy197

Reputation: 41

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

Upvotes: 0

Piyali
Piyali

Reputation: 506

.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 });

Upvotes: 0

Sarath Kumar
Sarath Kumar

Reputation: 2353

Try this using jQuery .css()

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

Upvotes: 2

ashanrupasinghe
ashanrupasinghe

Reputation: 756

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.

Upvotes: 0

Related Questions