Jump to content
Larry Ullman's Book Forums
nathanreed

Style Yii Pages

Recommended Posts

I am trying to establish a best-practice for styling yii generated pages. I just finished setting up the YII-booster extension and working up an in-line edit on a grid (Shout out to Larry on The YII book). 

 

For example what if you want to change the default blue color scheme? Larry has stated he does not use themes so I assume there is a good way to do this with layouts? It does not seem like changing main.css, screen.css etc would be sound practice although a copy could be made before installing updates etc.

 

Seems like changing page size, colors, fonts etc would be a very common practice but I find nothing on this topic. Plus I do not see a simple way to determine what css is associated with what page element?

 

Anyone have some suggestions or helpful reference they can guide me to? 

 

Thx much,

 

Nathan Reed

Share this post


Link to post
Share on other sites

There is no "YII best practice". This is totally related to CSS, HTML and front-end design, and has nothing to do with YII or PHP in general.

 

The way you want to do this is by overriding CSS. CSS is read top-to-bottom, and newer (declared later) )CSS properties overwrites older ones. (more to the top) I'll give you a concrete example using main.css and style.css.

 

main.css:

.something {
   margin: 10px;
   border: 1px gray;
   color: blue;
}

style.css:

.something {
   margin: 15px;
   border: 1px black;
   padding: 5px;
}

If style.css is loaded later in the HTML file than main.css, the class .something from style.css will overwrite the properties from main.css. That means it will change the margin to 15px and have a black border. The class will also have a padding of 5px, and have blue text.

 

This means you can basicly target anything main.css does in style.css. The reason why you want to do this is because you can then update main.css without losing any changes, and still override the styles.

 

Does that make sense?

  • Upvote 1

Share this post


Link to post
Share on other sites

Antonio:

 

Yes. Makes sense.

 

I did not ask my question very well. I was wanting to know the best way to place the css overrides within the YII structure and you addressed that. 

 

I started making the changes I need and it is working very well.

 

Thx for taking the time.

 

Nathan Reed

  • Upvote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...