spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Applying a Variable to a DIV CLASS In PHP


This is an odd thing to do, as PHP can only generate the initial HTML source that the browser receives. You're basically saying "I need the box at 100/200 and 100/500". In a battle between CSS rules, the most specific rule wins. Normally that'd be style="..." but in this case you didn't add the px unit to the inline style so the browser rejects it as meaningless.

The "quick fix" here is to simply fix that problem: echo "<div style='top:${top}px;left:${left}px' class='testbox'> but the real problem here is that you're specifying two positions mutually exclusive positions at the same time without a clear indication of why you're doing the override. Which position does it need? PHP runs server-side so it can't really have any idea why 100/500 is better than 100/200 (what are those numbers based on? Unlike on-page JavaScript, PHP can't check what is good positioning, so these are just magic numbers).

As simple positioning information for a specific element, it's much better to generate those positions as their own, named, CSS class such as:

.initial {
  top:  <?php echo $top_override; ?>px;
  left: <?php echo $left_override; ?>px;
}

and then in the HTML that you generate, use <div class="initial">... so that the master CSS applies, but the .initial class wins, setting the correct left value (since the top values are the same). Then, once the page is rendered by the browser, you'll have to use JavaScript to do any further dynamic positional changes.


Categories : PHP

Related to : Applying a Variable to a DIV CLASS In PHP
Applying OGNL expression to a context variable
Your variable most probably isn't a String so there isn't toUpperCase() method in it. The solution is to call toString() before calling toUpperCase(). <s:property value="#myVar.toString().toUpperCase()" /> Update Actually your problem is here <s:set var="myVar" value="%{#parameters.myVar}"/> since there could be more then one myVar in parameters it will return an array of Strings,

Categories : Java
Applying a function to consecutive subvectors of unequal and variable size
Below you find a solution using data.table: # reading in your data x <- read.table(text='MMM ABT 1991-01-02 11.01 2.58 1991-01-03 10.83 2.48 1991-01-04 10.80 2.43 1991-01-07 10.67 2.39 1991-01-08 10.39 2.42 1991-01-09 10.18 2.42 1991-01-10 10.33 2.43 1991-01-11 10.59 2.44 1991-01-14 10.60 2.38 1991-01-15 10.54 2.39', header=TRUE, row.names=1) # y <- read.table(text='portfolio_return 1991-0

Categories : R
how to avoid css jitters while applying css border with hover pseudo class
Use outline instead of border http://plnkr.co/edit/fijZ4wNazGLlx24gPGqS?p=preview .mybox:hover{ outline: #00FF00 solid thick; }

Categories : CSS
Calling a method from the super-class but using a local variable from the sub-class in java
You could have a method in class alpha : public char[] getValidCharacters() { return VALID_CHARACTERS; } Then you can override this method in the sub-class beta. And you use that method instead of accessing VALID_CHARACTERS directly.

Categories : Java
PHP. call static method of class which class name saved in static variable of other class?
Consider doing this: <?php class Dll_Main_Bla { public static function toBeCalled($anyParam) { return 'Elo, ' . $anyParam; } } class Main { public static $dll_bla = 'Dll_Main_Bla'; public function test() { $className = Main::$dll_bla; $x = $className::toBeCalled('Vincent'); return $x; } } $main = new Main; echo $main->test(); //should

Categories : PHP
Recently Add
Cartesian product of associative array showing key and value - PHP
Datamapper orm save and update not working
find methods in COM object
PHP Keyword search not working with multiple words
Set a total based on items ordered, two types, and sometimes one type will not be ordered.
FB request to join a group, going around their official SDK
Using Google charts with php data?
OAuth2 integration with ExactOnline
libvirt-php receives the error: unable to connect to server Permission denied
How to echo results by sets of 2?
Why does PHP's sprintf not round 5s reliably?
php replace affects on replaced string
PHP Find and replace multiple similar entries
Replace PHP date output with pre-made images
How to install Laravel 4 packages on Windows
Using updateOrCreate for multiple data insert in Laravel
Storing products in a MYSQL database and then search and filter them?
Create order with PrestaShop's API
how to get latest messages from all users
Yii CMultiFileUpload Restrict Image width
Combine array by key factor
Semicolon after if condition in PHP - code still works
Get date using day of the week
soap web service with symfony
Seasonal Reservation system Day/month
is it possible to join a single table it self?
Attempting to compare two arrays PHP
Sticky Select Option
Eventbrite duplicate event entry
Pagination Not Working on custom post type in Wordpress
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.