-2

Sorry for my English :) Is there a way to apply css rule for dynamic content (album of photos added by users)? I want to avoid inline style because each photo in the album counts as one style=.

HTML code:

<div class="sys_file_search_pic bx_photos_file_search_pic" style="background-image: url('__imgUrl__');">

I tried:

.sys_file_search_pic.bx_photos_file_search_pic {
    background-image: url('__imgUrl__');
}

but it doesn't work. Also tried:

<img src="__imgUrl__">

But photos are now unclicable and stretched.

My site: http://gracebook.pl.

Tompo
  • 341
  • 1
  • 2
  • 11

1 Answers1

0

You can't define this using only HTML. You can output the link for the image using PHP.

You should be using something like the following

<div class="sys_file_search_pic bx_photos_file_search_pic" style="background-image: url('<?php echo $variable?>');"> 

where variable is the variable holding the URL of the image.

kernel
  • 1
  • 8
  • __imgUrl__ is a variable and inline html style above works perfectly. I just want to move this style="background-image... to external style sheet. – Tompo Mar 05 '14 at 20:16
  • You can do similarly for the css. You just need to output php code in your style declaration Replace __imgUrl__ with – kernel Mar 05 '14 at 20:20
  • Like this? `code`.sys_file_search_pic.bx_photos_file_search_pic { background-image: url(""); }`code` – Tompo Mar 05 '14 at 20:48
  • SOLVED. I used `code``code` instead. had to apply some changes but it seems to be ok now. (ps. link was in php file). – Tompo Mar 06 '14 at 02:44