CSS: Problems with selecting html elements from CSS - css

I want to style a form in html using CSS. It's a really simple form, so I didn't expect to have any problems with accessing it with CSS selectors. But anyway, when I am trying to add something like:
#maincontent #left_side #comments{
margin: 100px;
}
or
#comments{
margin: 100px;
}
I see no visible effect.
Sorry, I think I am not very descriptive, but not sure how to describe the problem...
Maybe you could take a look at the demo url here:
http://chess-advices.com:8000/article/ololo/
And suggest how to fix my CSS, to pretify the form? (Well I actually just need to access it first)
Thanks in advance

You forgot to close this:
div.pagination span.disabled {
padding: 2px 5px 2px 5px;
margin-right: 2px;
border: 1px solid #f3f3f3;
color: #ccc;
display:none;
change this to:
div.pagination span.disabled {
padding: 2px 5px 2px 5px;
margin-right: 2px;
border: 1px solid #f3f3f3;
color: #ccc;
display:none;
}
To find this: Line 267 in your style.css or you can use strg/cmd + f to find it...
But i think, if you add something like this:
form label { width: 100px; display: block; float: left; }
form p { padding: 5px 0px 0px 0px; }
your form would look nicer :)
I hope this is the answer of your question...

There is an error earlier in the css file that causes this. There is no closing bracket on the style div.pagination span.disabled style, that makes the browser skip the rest of the css file.
Note: as an id is unique in a page, you only need #comments to target the element. The only reason to use #maincontent #left_side #comments would be if you need to make it more specific to override some other style, or if you use the style sheet for several pages and there can be other elements with the id comments that you don't want to target.

Related

Managing CSS priority

I'm making a blog and I am using a free template to manage my fron-end part, but now I want to add one class called code_block. Every time I write an article and I want to add a
<p class="code_block"> some code</p>
and the code piece to be displayed in a similiar to how this last code is displayed here in stackoverflow.
I went to the END CSS file entered:
.code_block{
color: #933 !important;
border: 5px solid red;
}
didn't work, tried adding the css directly in the html, didn't work, tried adding manualy the css while in chromium web tool, didn't work what is happening ?!
source: https://github.com/martin-varbanov96/summer-2016/tree/master/Pitonia/Django/mysql_blog/blog
EDIT:
made it more specific:
.ar
ticle ul li p .code_block{
color: #933 !important;
border: 5px solid red;
}
Still not working I think priority is not the problem here.
ID has got more priority. Remove the color from here. Or you can override.
#body.home .body div p {
color: #ffffff;
display: block;
font-family: Arial;
font-size: 18px;
font-weight: normal;
line-height: 24px;
margin: 0 auto;
padding: 0;
text-align: center;
width: 780px;
}
You can override it like this...
#body.home .body div p.code_block{
color: #933;
border: 5px solid red;
}

how do you create tags like stackoverflow with text styling

I was wondering how you can create css styling inside an input field such as stackoverflow's tagging system?
When you click on a tag, the text will be styled. And also, when you click on the styled tag, it will be normal again. I guess my main concern is how to style text inside an input field?
Thanks!
The tags are not input fields, they are links! On SO, the tags use the following styles:
.post-tag {
color: #3E6D8E;
background-color: #E0EAF1;
border-bottom: 1px solid #3E6D8E;
border-right: 1px solid #7F9FB6;
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
text-decoration: none;
font-size: 90%;
line-height: 2.4;
white-space: nowrap;
}
a.post-tag:hover {
background-color: #3E6D8E;
color: #E0EAF1;
border-bottom: 1px solid #37607D;
border-right: 1px solid #37607D;
text-decoration: none;
}
Only the bit you type in is an input, the other tags are just styled a elements. When you hit return, the input moves right and gets shorter, and the value is copied and a new a element is created.
The text in the input isn't styled.
This might help you: http://basdebie.com/jquery-plugins/jquery-tags-autosuggest-like-delicious-stackoverflow-facebook/
By looking at this code, you should be able to create something similar, or just use the plugin.

Space between two div tags

Hi I'm trying to set a space between two div tags but I don't know how to do it, I've been searching but I don't understand the examples that I've found
Here's the CSS code:
#logo{
position:absolute;
top:160px;
left:65px;
}
#desc{
position:relative;
margin-top:290px;
left:65px;
}
#desc_entry{
position:relative;
margin-top:5px;
left:65px;
}
.pressed {
color:#999;
padding: 10px;
background: #111;
border: 1px solid #000;
border-right: 1px solid #353535;
border-bottom: 1px solid #353535;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
this is the only way I've managed to get a separation between the div tags but the problem is that because I'm using the pressed class it fills the div with this style like this
http://i54.tinypic.com/uoux0.jpg
And i don't want it to be all filled. Any thoughts?
like other people said, you need to post the html or at least say what element do you want to add space to. This being said, I bet what you need is some clear:both somewhere, because that's the most common mistake on people starting with CSS

Create box with title/legend, in CSS

As a follow-up to this previous question, I'd like to add a title to a <pre> box, indicating what kind of code is inside it (e.g. R, sh, perl, ...). But I can't use a <div> as in the previous question, because the <pre> is generated by another tool (org-mode export). It looks like this:
<pre class="src src-R">
here <- is(the=code)
</pre>
So I'm hoping to create a src-R class that adds an R title to the <pre> box, in pure CSS, or if that's not possible, using some additional Javascript.
Any pointers appreciated!
You can do it using only CSS with .src-R:before.
See: http://jsfiddle.net/thirtydot/myAhS/
.src-R:before {
content: 'R'
}
.src-Perl:before {
content: 'Perl'
}
.src:before {
position: absolute;
top: -10px;
background: #fff;
padding: 5px;
border: 1px solid #000
}
.src {
position: relative;
padding: 25px 9px 9px 9px;
border: 1px solid #000
}
:before works in IE8+ and all modern browsers.
If you need IE7 or lower support, JavaScript will be needed.

Remove extra button spacing/padding in Firefox

See this code example: http://jsfiddle.net/Z2BMK/
Chrome/IE8 look like this
Firefox looks like this
My CSS is
button {
padding:0;
background:#080;
color:white;
border:solid 2px;
border-color: #0c0 #030 #030 #0c0;
margin:0;
}
How can I change the code sample to make the button the same in both browsers? I do not want to use JavaScript based hyperlinks because they do not work with space bar on keyboard and it has to have an href URL which is not a clean way to handle things.
My solution, since Firefox 13
button::-moz-focus-inner { margin: -1px; padding: 0; border-width: 1px; }
Add this:
button::-moz-focus-inner {
padding: 0;
border: 0
}
http://jsfiddle.net/thirtydot/Z2BMK/1/
Including the border rule above is necessary for buttons to look the same in both browsers, but also it removes the dotted outline when the button is active in Firefox. Lots of developers get rid of this dotted outline, optionally replacing it with something more visually friendly.
To fix it on input elements as well add
input[type="reset"]::-moz-focus-inner,
input[type="button"]::-moz-focus-inner,
input[type="submit"]::-moz-focus-inner,
input[type="file"] > input[type="button"]::-moz-focus-inner
is simple perfect!
Corrected version of #thirtydot's answer:
button:: {
padding: 0px;
border: 0px;
}
button::-moz-focus-inner {
padding: 0px;
border: 0px;
}
Regarding Firefox 87:
button in button::-moz-focus-inner cannot be a class. (E.g. .mybutton::-moz-focus-inner does not work)
There must be a button { padding:0px; border: 0px; } style present as well (This style can be given per class).

Resources