CSS problem with include - php

I don't really need help with the code, but I have a question about CSS and PHP. I'm still trying to learn CSS. Please forgive me if I have problems explaining properly.
My website is made up of several .php scripts that always calls from my main include php script. This script contains the header, overall layout, login check, javascript, and scripts that fix errors and log certain stats. This include file calls my style.css sheet. So, every page loads the style.css because every page calls my include file.
Here is my problem.
ul{
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
}
li{
margin:0px 10px 3px 10px;
padding:2px;
list-style-type:none;
display:block;
background-color:#606a86;
width:125px;
This is for a menu. I haven't used this a lot, because I'm still learning, but that code works perfect for the menu I use with javascript. But, I want to use ul and li elsewhere on my site, but I don't want the same look. Basically, I want to have a different look elsewhere when I use class="". Problem is, if I try add a ul.example or li.example it doesn't work like it does on other tags when using class="".
I've also tried directly adding the css to the page, but it still loads the style I have for the menu.
Note that I have tried giving both separate ids, such as ul.ex1 and ul.ex2, same goes for the li.
Am I just completely lost with CSS, or is there a certain way to do this?

You should bind your ul/li to an element. For example if your menu is within
<div id="menu">your menu</div>
You should have your CSS like so:
#menu ul{
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
}
#menu li{
margin:0px 10px 3px 10px;
padding:2px;
list-style-type:none;
display:block;
background-color:#606a86;
width:125px;

Your CSS selector is backwards. It's tag then classname, i.e. ul.example not example.ul
Check out this quick tutorial.

Your best bet is to give your navigation bar a class and assume all other ul's and li's have their normal state. Then, it will be easy to change those normally on any other pages you create.
Just a note, if you wanted to create a class for ul, you'd use ul.navbar and ul.navbar li, which is much easier than applying the same class to each individual li.
<ul class="navbar">
<li></li>
<li></li>
</ul>
<style type='text/css'>
ul.navbar {
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
}
ul.navbar li {
margin:0px 10px 3px 10px;
padding:2px;
list-style-type:none;
display:block;
background-color:#606a86;
width:125px;
}
// all other uls remain normal
</style>

Related

Creating a smart button menu in Drupal with in block div and css style

Hi I've been trying to create a smart button menu set in an drupal block that remembers which button has been clicked (which site it is on). For reasons that don't matter, it is not a menu it's an in-block item. I created the following in-line:
<div>Overview</div>
<div>Instruments</div>
<div>Travel</div>
This coupled with the following css produces lovely buttons:
.button {
background-color: #61210b;
color: white;
float:left;
padding: 2px;
border: 2px solid #000000;
border-radius: 5px;
text-shadow: 1px 1px #000000;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-family: 'verdana';
margin-bottom: 10px;}
.button:hover {
background-color: green;
color: white;}
.button:focus {
background-color: green;
color: white;}
.button:active {
background-color: green;
color: white;}
So everything above works great. However, the green activation color does NOT stay. As soon as I go click it goes back to what it was before. I want it to 'show' the page it is on with it's color change and only the currently chosen button will have the green color. What I have not works great except for that little issue. I've read around on the site a bit and here are some things that do not work:
--> inline php, creates errors link unreadable, if I define a class as selected with a different color, this does NOT work:
Overview
What also does not work is defining an additional class in the <a href > or <div> to make it 'selected', at best if I use the css file and do
.selected a { color: green; }
#selected a { color: green: }
I can permanently change the color to green, which is not what I want at all. I saw the discussion previously of using lists <li id="selected"> to create menues but not only does this not give me very nice buttons like my div format does, it also flat out does not work. See: CSS: How to change colour of active navigation page menu
The color just changes permanently, I only want it to change color if page=page of link. Since I'm using div this means I also cannot use the other pseudo-class-selector tricks like :target or :root. I have a feeling php is the way to go but I don't know why it can't be read in-line from my drupal box item. It has no problems with html or css in-line. Any ideas?
Try this code
CSS
.button:active, .button.selected {
background-color: green;
color: white;
}
PHP
Overview
what you wrote is calling for something else...
.selected a is targeting any element with the class "selected" which is inside an anchor tag, what you mean is an anchor tag which has the class selected = a.selected
ok, so I heard back from our system administrator and Drupal safety settings do not allow for in-line php or java scripting. There is literally no way to do this with div statements. The only way is to delete everything and make a new block of type menu block. In a menu block the psuedo-class :active will stay active if you use css
li .active
otherwise you can try to get php enabled but most drupal areas do not allow that or java scripting (at least it's not allowed where I am).

Centralize Website and logo

I want my page's logo and articles to be in the center of the site. At the moment everything is on the left.
I just can't make it work.
For Example I tried to delete the wrapper and set margin-left:auto; margin-right:auto; in the logo's class. nothing works.
And for the posts i just don't know where to start. probably i would have to put everything in a container and make that central? (There should be three posts in a row, at the moment the theme stacks them up to the right screen border if you have a big screen)
Thank you so much.
EDIT: The Text align in the image class did the job. Thank you guys, question answered!
#logobild {
margin-left: auto;
margin-right: auto;
text-align: center;
}
That will do it for you :) Your header takes up 100% of the space, so the content inside has no fixed dimensions to center against. The text-align value assists with that.
Try:
#logobild {
margin-left: auto;
margin-right: auto;
text-align: center;
}
To center the logo you can do the following in CSS:
img {
display: block;
margin-left: auto;
margin-right: auto;
}
The img element is inline by default, which means your margin styles won't be applied to it. When it is set to block level the margin settings will work.
To center the articles I suggest you give a width to the container div like this:
#post-area {
width: 85%;
margin-left: auto;
margin-right: auto;
}
I'm not sure if that's the best way, but it seems to work.

Different width's on front and article page

So i'm making this site which is based on wordpress for adding dynamic content but i have set up an entirely HTML/CSS and little jQuery built theme.
The issue i'm facing is when I had to place the front page posts like teasers with a link to the entire post
teaser like this :- http://i.gyazo.com/dda9c60eb3a822b84bdcb3e0067dfc3e.png
as i knew nothing about wordpress themes, i took help of esclate's php files and just made up a code that could harbour my css classes,id's and properties with it.
Hence to start with, the post's elements in header.php was setup like this :-
<div class="post-wrapper">
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="content">
that was the same for the single.php file,
i successfully made the site have teaser posts for the front page but the issue arrived when the same properties of those above ID's got called to the single.php file as the classes and id's were similar, which is shown/open when the user clicks on full article,
i made another class for the single.php post elements but it had no effects.
here is what it looked like :- http://i.gyazo.com/0ec25c1db676463dd6aea209480e9568.png
it shows a teaser and not the full post, how can i rectify this?
btw the css code for them all
#page {
width:100%;
margin: 0 auto;
padding: 0;
display: inline-block;
}
#page-bgtop {
}
#page-bgbtm {
margin: 0px;
padding: 40px 50px 0px 50px;
}
#content {
float: left;
width: 100%;
padding: 0px 0px 0px 0px;
margin-left: -40px;
padding: 20px;
display: inline-block;
margin-bottom: 40px;
font-family: 'Raleway',Arial,sans-serif;
font-size: 14px;
line-height: 23px;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
}
I hope i have discreetly explained everything in my grasp for this issue.
As you are dealing with id's the same will be applied where-ever the id's are used, it overrides classes by default. You can create new id's or add class="" in your html so in your css you can mark elements !important to override the id content. This gets messy though so you would be better to change your ids to classes in the above example and use id's to make small changes to the class in the different pages.

Draw an image on web site at the end of the script

I have a little problem. At the end of my R script I create an image .png as output. I wanna show this image on my website but sometimes it is drawn, sometimes it is not drawn. I don't understand how it is possible. I`ll put my code:
I insert the image in a div with this features:
#diagramm {
position: relative;
border: 2px solid #333;
border-color: #6495ED;
width: 820px;
height: 370px;
margin: 2px auto;
margin-top: 2em;
background-image: url("/home/daniele/public_html/appweb2013/venn_final/fungo_final.png");
}
Where is the mistake? Can I use a better method?
This is CSS, it only puts specific design rules for an element that has the id diagramm.
So what you've posted is not code so to speak.
In what way do you generate the output? When? what does the user do to generate it etc.
Do you have any javascript or html code you can show?

Image in text line is slightly offset

I'm trying to make a clickable button by treating a hyperlink with CSS and adding a little icon next to it. Everything but one detail works great; namely the icons which are slightly offset from the text on the button. It looks as follows:
As you may see, the white icons (12x12px) on the buttons are slightly higher than the text, touching the CSS borders of the hyperlink, while the rest of the text does not.
I have tried every solution that came to mind, including applying vertical-align to the image elements (which put the icon too close to the LOWER border instead, reversing the situation), but sadly could not get it to just line up with the text in the middle of the element nicely. What should I do?
Code in question:
HTML example of a button:
<td class="headerlinks">
<img src="{T_THEME_PATH}/images/icon_mini_login.png" alt="*" /> {L_LOGIN_LOGOUT}
</td>
CSS of the buttons:
.headerlinks {
margin: 0px 0px;
font-size: 1.1em;
line-height: 200%;
}
.headerlinks a img {
}
.headerlinks a {
white-space: nowrap;
border: 1px solid #FAE000;
padding: 1px 4px 2px 4px;
border-radius: 4px;
margin: 0px;
background-color: #000;
vertical-align: middle;
}
Are you using a CSS reset? You can try the following one.
http://meyerweb.com/eric/tools/css/reset/
Also it's better to use a background-image for the icon, and set a position on it.
This should work if you add margin-top:2px; to the icon class. This number may need to be shifted by a digit or two.
This will work if you maintain the static font-size.

Categories