My web2py project has an html file that contains only these two lines of code
{{extend 'layout.html'}}
{{=form}}
I want to write some inline css that should override the css that will be loaded from layout.html. I want to know if this is possible and if so, then how?
Here's the style that I want to add
.error {
margin-top: 0px
}
Here's how you can add inline CSS:
{{extend 'layout.html'}}
{{=form}}
<style>
.error {
margin-top: 0px;
}
</style>
Related
Let’s say I have a few utility classes:
.primary-text {
color: blue;
}
.danger-text {
color: red;
}
.display-400 {
width: 400px;
}
.max-width-100 {
max-width: 100%;
}
Do classes like this require the !important keyword?
If you have some other CSS files that are loaded before this file, you have three ways to force your CSS content to load:
add !important
add your CSS file link tag at the end of another link tag
find a more accurate selector for your tag like this:
span.primary-text {
color: blue;
}
This code has higher priority.
But if you don't use any other CSS file that contains these selectors with the same properties, you don’t need to use !important.
I need to surcharge Bootstrap CSS and for that i have created a new overwrite.css file.
In my different test I need to display a black background (It's only for test) but nothing.
<div id="myBackground"> </div>
CSS:
#myBackground { background-color: black; width: 100px; height: 100px; }
so i don't know where exactly you need change the bg color use these after bootstrap or in <style></style> inside <head></head>
if you want change the page background
body {
background-color: black !important;
}
if as container or column
col-md-5 {
background-color: black;
width: 100px;
height: 100px;
}
Make sure you are selecting your element with more specificity than the bootstrap css.
Load your overwrite.css file after bootstrap.
Try selecting a parent element before your #myBackground div. For example,
.main-content #myBackground {}
Find the attributes bootstrap is using that you want to override... for example if in bootstrap.css there is .navbar-nav {background:#000;} then you need to make sure your overwrite has a background attribute declared, such as #myNavbar {background:#555;}
overwrite.css : "It means what it means"! You can't create your own id or class if bootstrap doesn't know what is this...
So, you must create a third css file (style.css for example) and load this after bootstrap.css and overwrite.css !
After this, all is working!
Thanks
I'm creating a chat widget and I want to overwrite a bunch of CSS. For example if this is the website theme's CSS:
textarea {
color: red;
margin: 10px;
}
and if I style my widget like:
textarea {
padding: 5px;
}
then only my widget's CSS should work. However, it adds both CSSs to textarea by default - how can I prevent the website's CSS from being added?
As Marc B stated, you can put your chat in an iframe, in which case you can have its own completely separate stylesheet.
If you must use it inline, then you can use all css property to unset what has been set elsewhere:
Widget CSS:
textarea {
all: unset;
padding: 5px;
}
Further, as pointed out in comments elsewhere, the best way is to create different classes for text area and use them where necessary, for example:
textarea.main {
color: red;
margin: 10px;
}
and if I style my widget like:
textarea.chat {
padding: 5px;
}
And then use
<textarea class="main">
or
<textarea class="chat">
depending on what you need.
Well I guess it is really easy to write !important to all your css rules. Just replace ";" with "!important" if that's an easy way for you OR if you really want to change then you can use iframe really
I have just started to explore GWT, and i'm bit confused with different ways of applying styles to GWT widgets.In gwt docs, there are 4 ways by which you can override default style of a widget,
1) Using a tag in the host HTML page.(Deprecated)
2) Using the element in the module XML file.(Deprecated)
3) Using a CssResource contained within a ClientBundle.
4) Using an inline element in a UiBinder template.
Suppose i have a CSS file in some package say, com.abc.xyz.styles.css .And the file has the following contents,
/**the panel itself**/
.gwt-TabLayoutPanel {
border: none;
margin: 0px;
padding: 0px;
}
/**the tab bar element**/
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTabs {
background-color: #F4F4F4 !important;
}
/**an individual tab**/
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTab {
background-color: #6F6F6E !important;
}
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTab-selected {
background-color: white !important;
}
/**an element nested in each tab (useful for styling)**/
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTabInner {
font-family: Arial !important;
}
/**applied to all child content widgets**/
.gwt-TabLayoutPanel .gwt-TabLayoutPanelContent {
border: none;
margin: 0px;
overflow: hidden;
padding: 15px;
}
How will i inject this css file ? How can this be done using the 3rd and 4th option of styling mentioned above?.
You can simply add your CSS file to the host page. Then you can use the full power of CSS selectors. This is my preferred method of using CSS in GWT:
What the best strategy to structure CSS in GWT?
I want to remove the following from an html page and add it to an existing css sheet. Do I have to do anything special like creating a new .mynewclass or simply remove the <style> tags?
<style>
<!--
.rightAlign
{
text-align:right;
}
.leftPad05em
{
padding-left:0.5em;
}
.bottomPad05em
{
padding-bottom:0.5em;
}
.topPad05em
{
padding-top:0.5em;
}
.topBottomPad1em
{
padding:1em 0em 1em 0em;
}
.bottomControl
{
padding-left:14.5em;
}
-->
</style>
add your styles to a external stylesheet for example - default.css
Include these in that stylesheet -
.leftPad05em { padding-left:0.5em; }
.bottomPad05em { padding-bottom:0.5em; }
.topPad05em { padding-top:0.5em; }
.topBottomPad1em { padding:1em 0em 1em 0em; }
.bottomControl { padding-left:14.5em; }
and in your header include this -
<link href="default.css" rel="stylesheet" type="text/css">
This is calling the default.css style sheet. Note, href="value" would be where the style sheet is located
If the existing CSS file is already imported in the HTML, then moving the inline CSS from the HTML to the file should work.
In this case it sufficient to write the embedding css code in your CSS file. Check if the classes already exist. If so, add the CSS atributes to these classes otherwise paste the code into the file.