Jump to content

Recommended Posts

Hi

 

I am trying to reset the width of a selected image to 99px in my php page. So i used the css * universal rule to reset the value.

 

Please find below the code snippet:

 

<style type = "text/css">

.faculty-image {

max-width: 99px;

border: 1px solid #999;

}

 

* html .faculty-image { width: 99px; }

</style>

 

<?php

//php code which retrieves the images

echo '<td valign="top"> <img class="/faculty-image/" src="'.$test.'"/></td>';

?>

 

The above code did not reset the width.Hence i made changes like:

* img { width: 99px; }

 

But this is resetting all the images on the page.

 

Please help me in this. I dont know how to apply the reset to that specific image which im echoing.

 

Thanks in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/199152-using-css-universal-rule/
Share on other sites

But this is resetting all the images on the page.

 

That is not possible with the above CSS rules it's most presumably some other line that does that which is not shown in the above example as the rule that includes the *-character tells the browser to apply width: 99px on all elements that has a child-element  HTML that has a child-element with class .faculty-img which is none as no element contains the root element.

 

* html .faculty-img therefor should be .faculty-image

 

Also class="/faculty-image/" is incorrect and should be class="faculty-image"

@f1fan - thanks for pointing that out but earlier i had tried to use the class and the rules were not being applied.hence i was using the / as someone pointed out that its the way to do it.

 

@ignace - the browser creates a internal document tree representing all the HTML elements in the page to display.Then it reads the css rules and starts applying them to the element/s that match the selector specified in the rule. You can read more on this at http://webworksconsultant.com/frontend/what-is-wrong-with-universal-css-selector/.

 

So i placed my class at the end of the img tag.

 

Its working now.

 

Thanks! :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.