Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have no HTML or CSS experience but trying to figure out what exactly this line of code means
<div class="overflow-100">
It has an affect on how wording appears on our portal and not sure if it's limiting words to 100 characters, 100 pixels or something else
overflow-100 is a user defined class that css selectors can target. Without seeing selector/s targeting overflow-100 we have no idea what declarations it applies. Open the document in the browser, open dev tools (f12), inspect element (ctrl+shift+c) and hover over the div with the class overflow-100. In the styles tab find a rule with a selector overflow-100 and you will see css declarations it applies. Googling for those rules will give you a understanding of the effects of the overflow-100 class.
Class names are purely user data. Neither HTML nor CSS assign any special meaning to them so they don't accomplish anything by default.
Their purpose is to assign custom information that can be leveraged later from other tools (JavaScript, CSS, accesibility tools, web crawlers...).
Here's a quick and dirty showcase:
document.querySelectorAll("div").forEach(function(box){
box.classList.forEach(function(className){
let fragments = className.split(/^foo-(\d+)$/);
if (fragments.length === 3) {
box.innerHTML += ` <strong>Type ${fragments[1]}</strong>`;
}
})
});
div {
border: 1px solid orange;
}
.foo-100 {
width: 100px;
}
.foo-200 {
width: 200px;
}
<div class="foo-100 something-else">Hello, World!</div>
<div class="foo-200">Hello, World!</div>
To help figure out what your application is currently doing with them you can use the browser developer tools. For instance, here:
document.querySelectorAll("div.bar").forEach(function(box){
addEventListener("click", function(){
alert("You've clicked on bar");
})
});
div.bar {
color: green;
}
<div class="foo">Hello, World!</div>
<div class="bar">Click me!</div>
... you learn you have an event listener and an inline style (please note anyway that this example is an Stack Overflow snippet, which is more complex that regular code):
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Given the following CSS and HTML, why does it produce a blue background?
div div { background-color: blue }
.myClass { background-color: green }
<div>
neither green nor blue
<div class="myClass">
should be green but is blue
</div>
</div>
If I understand selector calculation correctly, the first rule should evaluate to 0:0:2, while the second should evaluate to 0:1:0. https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity mentions inherited styles being overridden, but this is a direct application of class on the div, not an inherited style. What am I missing here?
UPDATE
I am working in Angular 8, and here's a screenshot of the thing that's been confounding me. So...since this works outside of Angular, is this somehow an Angular issue?
Here's the devtools console, showing the override and the css rules...
After looking closely at the CSS style calculations in the second image, I think I realize now what's going on. If someone can confirm this, I'd appreciate it. The generated CSS
div[_ngcontent-xpy-c52] div[_ngcontent-xpy-c52] {
appears to have attributes attached. Those attributes ratchet up the class score of the div div rule, making it override the .myClass rule. Even though the original CSS does NOT contain those attributes, what basically every browser sees is what I have quoted here, and so the outcome at runtime is quite different from what one would otherwise expect.
enter image description here
Your code worked correct. Here my code.
<style>
div div { background-color: blue }
.myClass { background-color: green }
</style>
<div>
neither green nor blue
<div class="myClass">
should be green but is blue
</div>
</div>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
My home page styles work perfectly fine but when I keep coding the css for another html page, the layout breaks in the home page. For example, I have some content in the home page but I want to remove them in other pages and when I do, it breaks the layout in the main page and if I try to fix then the second page won't be the way I want. How do I fix this?
You've got to read some CSS books/guidances.
A very brief info to see (part of) what you can do:
Use different class names for differently styled sections. You can combine classes like this:
<div class="box headerpage">....</div>
<div class="box innerpage">....</div>
and in CSS it would be:
.box {
// main style
}
.box.headerpage {
// addition for header page (element with headerpage class specified
}
.box.innerpage {
// addition for inner page (element with innerpage class specified
}
You can also alter the style dependant on element's ID:
#myDiv.headerpage {
}
#myDiv.innerpage {
}
you need 1 css file for all pages. use different classes an ids and then your css will not override previous settings
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there a way to override every style property using a method similar to the !important declaration.
I want to override all properties without changing the order of the loaded stylesheets.
I'm also not able to change different stylesheets
EDIT
Might there be a way to put !important on an element?
You could be more specific in your styles.
For example, if you had HTML like this:
<div id="greg">
<p class="likes">
Hello, something <span class="toast">more</span>.
</p>
</div>
This:
span{
color:red;
}
would be over written by this:
#greg .likes .toast{
color:blue;
}
Instead of slapping !important everywhere, just make your styles more specific.
JSFiddle
Alternatively, if you can't actually edit the CSS file, you could always try inline styles, although they're harder to overwrite and shouldn't REALLY be done unless 100% necessary or you're applying styles through javascript etc...
example:
<div style="color:red">Caterpillar</div>
You should use weight of css selectors.
Good article by Chris Coyier
So you can increase the weight of your selectors using body tag for example.
div {
background: red;
height: 150px;
width: 150px;
}
body div {
background: blue;
}
the only way to do it would be to apply a !important style tag to the element in itself since this would then take preference over the style sheet declaration.
with simple html:
<p id="foo" style="color: blue!important;">LOREM IPSUM</p>
http://jsfiddle.net/vimes1984/5KbGV/
With JS:
$('#foo').attr('style', 'color:green!important');
http://jsfiddle.net/vimes1984/5KbGV/6/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What is this? Button or Select ? How do like this by HTML and CSS ? Thank
This is most probably a styled select element. Take a look at this tutorial http://css-tricks.com/dropdown-default-styling/
This can be a simple div with 3 elements in it.
1) The image - with the top and the bottom arrow.
2) The ul tag - when clicked on the image, the ul's get displayed.
3) The label - when any of the li's is selected, its value is copied to the label
you can do thing like this with simple div. something like that
<div id="button"><span>Location</span></div>
#button
{
width: 100px;
height: 40px;
background-color: grey;
border-radius:15px;
position:relative;
}
#button>span
{
position:absolute;
top:10px;
left: 10px;
}
I actually made a plugin that lets you do this here is a link; just download the files include the script and css run
$('document').ready(function(){
$('select').niceselect();
})
and you can then style it however you want using css.
http://projects.authenticstyle.co.uk/niceselect/
This is a Select element.
Check this Example : dropdown list
advice how to solve that kind of problems
IF you are using Chrome,Firefox... you can right click on any element on page then inspect element
and see HTML CSS even JS for that element
Read more about Chrome Developer tools
https://developers.google.com/chrome-developer-tools/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
So I Have a black and white picture as my background, and I'm making the contact page for my site. Everything is going smooth the only problem is I want to make a transparent button that has a white border around it like on http://yokedesign.com.au/contact/ any ideas?
You just need to make the background-color: transparent of the button:
Fiddle: http://jsfiddle.net/TQ357/
Then, you could make the border transparent as well if you wanted it to be completely blended in with the background.
The particular example you cited is an anchor tag with a border added to it. It has been styled using inline css, which is not best-practice, but could easily be moved to an external css file. Most of the big browsers include developer tools either bundled or as a plugin. With these tools you can right-click and inspect an element on the page and see the html and styles applied.
Looks like your example uses an <a> anchor with CSS styling and a JS handler. Here's some CSS:
a.contact-submit {
border: 1px solid #FFF;
padding: 5px 10px;
float: right;
color: #FFF;
}
And the anchor (let's say you're using jQuery):
<form id="form-name">
SEND
</form>
<script type="text/javascript">
$(document).ready(function() {
$('.contact-submit').click(function(e) {
e.preventDefault();
$('#form-name').submit();
});
});
</script>