Xaringan: How do you change code chunk background color? - xaringan

Is it possible to change the background color--and other attributes--of code chunks? Is there a class associated with code chunks?
Modifying the background color for inline code is simple:
.remark-inline-code{
background-color: #000000
}
But I am unable to find an equivalent specifically for code chunks.

Inspecting the div using Chrome developer tools, you see that the color is set by class .hljs-github .hljs.
Setting
.hljs-github .hljs {
background: red;
}
should do what you want :)

Related

An auto-scaled on-off background image in a QLineEdit

I have a couple of QLineEdit widgets that need to have their backgrounds appear and disappear upon certain code changes, and need those backgrounds to also rescale when widget size changes.
I am getting quite lost in all the stackoverflow and documentation on the Qt website. My main point of confusion is how I register only specific widgets with a paintEvent function I make.
In pseudo-ish code, I've been led to believe that my auto-scaling background image idea requires some combination of QPainter and QPixmap:
void MyGUI::paintEvent(QWidget mywidget, string path){
QPainter painter(mywidget);
QPixmap _mypix(path);
int widgetHeight = mywidget.height();
int imageHeight = _mypix.height();
float imageratio = _mypix.width()/_mypix.height();
if(imageHeight > widgetHeight){
painter.drawPixmap(0,0,imageratio*widgetHeight, widgetHeight, _mypix);
}
else{ painter.drawPixmap(0,0,_mypix.width(), _mypix.height(), _mypix);}
}
Then in the main UI, I want to call the above function situationally to turn on and off this background image. While the image is on, though, I want it to resize as per the above function (aka depending on its widget's height, not the main GUI height):
Blah blah constructor stuff
{
ui->setupUi(this);
paintEvent(ui->widget1, "path\to\background1.png");
paintEvent(ui->widget2, "path\to\background2.png");
connect(this,SIGNAL(MaybeTurnOffBackground()),this,SLOT(TurnOffBackgroundSometimes(bool)));
}
void MyGUI::TurnOffBackgroundSometimes(bool backgroundOn)
{
if(backgroundOn)
{
paintEvent(ui->widget1, "path\to\background1.png");
paintEvent(ui->widget2, "path\to\background2.png");
}
else{
//something that removes the images
}
}
Hope it's clear enough. I have no idea how to make this type of behavior come about. I get the sense I am somewhat overcomplicating things by using the paintEvent business, but I'm not sure what the alternative is.
Solved my own problem. Ended up doing it entirely in stylesheets. I don't know what my philosophical opposition was to using image instead of background-image, aside from the worry that it would interact poorly with text that is inputted into the QLineEdit. Thankfully that is not a concern, and text receives the most Z height in the box overall so the image will still appear behind it.
Some answers have specified that you need a border, e.g. "border: 1px solid white". I tested first with border, then without, and it functions the same so I left the border out. YMMV.
#myWidget1{
image: url(":/main/assets/myAsset1.png");
image-position: left;
padding: 5px;
}
Regarding the on-off feature... I'd actually already solved this. I just created a custom property, and toggled it off and on in SLOTS as necessary.
Stylesheet:
#myWidget1{
background:rgba(125,0,0,55);
}
#myWidget1[status="active"]{
image: url(":/main/assets/myAsset1.png");
image-position: left;
padding: 5px;
}
Sample code in a slot:
if(active){
ui->myWidget1->setProperty("status","active");
}
else{
ui->myWidget1->setProperty("status","notactive");
}
The nice thing is I don't actually have to define what style "notactive" takes in the stylesheet. It just defaults to the baseline style.

Django infinite scroll messed up design. CSS need correction

I am developing one website using Django. The website link is,
http://flooroof.com/listings/
You can see that the tiles on the website has got overlap on each other. This happened after I implemented infinite scroll. I found it at below link,
https://simpleisbetterthancomplex.com/tutorial/2017/03/13/how-to-create-infinite-scroll-with-django.html
If you scroll down you will see more and more properties are getting loaded. At a time I am loading 20 listings. But not sure what has gone wrong.
I know there is something wrong with CSS but I am not sure what it is.
Please guide.
Yes as I can see the CSS has issue especially in .grid-item present on after first .infinite-item. I .grid-item has absolute position and only first .infinite-item's .grid-item has proper left and top values. If you want a quick solution then you can do this.
a.grid-item
{
left: auto !important;
top: auto !important;
position: relative !important;
}
One more issue is with image size. your images size are very different from each other so best solution is to use a blank 1px trasparent image with fixed height and show current images as background image.

Height restriction?

Please help with these two issues, I will happily pay$ to get these two obstacles out of my way. I got this template from envato and my skills are very slow progressing.
http://philpadilla.com/demo/project.html
Fashion Models
Mobile ยท Web
How do I edit the css to expand the image heights to 100%? My graphics will be stacked just like the template but they will vary in height and I need them to not have the tops and bottoms of the images clipped off. I have been digging and cant seem to find the solution. I also want to turn the rollovers off on all the project images. Does anyone have it in their heart to help please?
The images on your template are already with a predefined value, to change that, you can:
Edit the inline style of your image
Create a external stylesheet to change the height
You can try setting height to 100% (height:100%;)
The easiest way to turn the rollover of, is creating a new stylesheet (style.css) and including it on your code (<link rel="stylesheet" href="style.css">)
thumb-overlay { display: none; } /* This code will disable the rollovers */ }
img { height: 100%; } /* And this one will set all pictures height to 100% */

Set background color of an PDF generated using libHaru

So I am trying to set background color in C++ using libHaru for my new pdf.
I am having issues setting it. Searched through documentation and either was not there
or I missed it.
Anyone who knows how to set background color for pdf page?
Also any comments on libHaru? Would you recommend it etc would be awesome.
Thanks
There is no background color for a PDF page. If you want to make the page red, for example, you draw a rectangle that covers the page and fill it with red.

swapping background colors in gtk text field (gtkmm C++)

Within my GUI (C++, GTKMM 3), i have a text field that is providing some status information. i'd like to change the background color of this field (along with the text, which i can easily do), based upon the status.
there's not a lot out there on how to do this with GTKMM 3.X. i know i need to use the CssProvider class, and have found some examples on how to load one into the program. but the examples show how to set the properties one time.
but what i haven't figured out is how i can use the CSS properties to change the color of the background, based upon a state (not a state as in 'hover' or anything like that. i want to be able to swap the background from red to green whenever i please). if the CSS is written in terms of using the name of the widget, or the type of widget, how do you handle a changing state with the widget to change its properties?
if anyone has any clues, or knows of any examples, i could really use some help. the purpose of this is to give the user some immediate feedback at a glance. in a rush, they won't have to read the status of the box (or from a distance). the color will allow them to gauge what is going on at a glance.
Adding code
this is what i have tried so far (condensed):
std::string style_sheet = ".red_bg {background: #FF0000; color: #000000; } ";
style_sheet += ".green_bg {background: #33FF33; color: #000000; }";
Glib::RefPtr<Gtk::StyleContext> stylecontext = my_text_field->get_style_context();
Glib::RefPtr<Gtk::CssProvider> cssprov = Gtk::CssProvider::create();
cssprov->load_from_data(style_sheet);
stylecontext->add_provider(cssprov, GTK_STYLE_PROVIDER_PRIORITY_USER);
stylecontext->add_class("red_bg");
stylecontext->context_save();
so that works. when the program fires up, i get a text entry with a red background.
but later on, if i do the following, nothing happens:
Glib::RefPtr<Gtk::StyleContext>stylecontext = my_text_field->get_style_context();
stylecontext->remove_class("red_bg");
stylecontext->context_save(); // probably not necessary
stylecontext->add_class("green_bg");
stylecontext->context_save();
at that point, the background stays red. no transition from red to green. i've seen suggestions to use the override_background_color function in the GtkWidget object, but that doesn't work. that only changes the color that is used when you highlight the text in the widget. i'd still like to see it done the CSS way.
You could do away with the CSS and just use override_background_color, a standard GTK widget method:
override_background_color (StateFlags state, RGBA color)
Sets the background color to use for a widget.
All other style values are left untouched.
Note:
This API is mostly meant as a quick way for applications to change a widget appearance. If you are developing a widgets library and intend this change to be themeable, it is better done by setting meaningful CSS classes and regions in your widget/container implementation through add_class and add_region.
This way, your widget library can install a CssProvider with the STYLE_PROVIDER_PRIORITY_FALLBACK priority in order to provide a default styling for those widgets that need so, and this theming may fully overridden by the user's theme.
Note:
Note that for complex widgets this may bring in undesired results (such as uniform background color everywhere), in these cases it is better to fully style such widgets through a CssProvider with the STYLE_PROVIDER_PRIORITY_APPLICATION priority.
Parameters:
StateFlags state the state for which to set the background color
RGBA color the color to assign, or null to undo the effect of previous calls to override_background_color