Locally Disable Padding

Locally disable padding

Use the #pragma pack directive for that:

#pragma pack(push, 1)
struct foo {
// etc..
};
#pragma pack(pop)

How to remove padding or margin in Vuetify?

use spacing helpers:

class="ma-0" removes margins

class="pa-0" removes padding

class="ma-0 pa-0" removes both

Note that these are also props but only for some (grid) components so for example:

<v-text-field class="pa-0"></v-text-field> will work,

and <v-text-field pa-0></v-text-field> will not work.

Classes are added on top-level element so if in some components you can't remove child-element(s) spacing with these classes, then likely you need to target relevant elements with CSS.


To avoid using !important, add custom class on the component and inspect element which you want to edit and then check what's used for targeting it - for example .v-input__slot (we only need highlighted target):

Sample Image

Then replace it like so (custom-text-field is arbitrary custom class applied to the component)

.custom-text-field.v-text-field.v-text-field--enclosed .v-input__slot {
padding: 0;
}

How to tell gcc to disable padding inside struct?

In GCC you can use __attribute__((packed)) like this:

// sizeof(x) == 8
struct x
{
char x;
int a;
};

// sizeof(y) == 5
struct y
{
char x;
int a;
} __attribute__((packed));

See doc.

Also if you rely on the addresses of struct fields, take a look at the offsetof macro. Maybe you don't need to pack the structure at all.

how to remove extra padding covered with carousel controls

As you're using Bootstrap, the .container class has padding-left: 15px & padding-right: 15px styles.

container has padding

Just set padding: 0 to your .container class and it's all done.

However, be careful that in the screenshot below, you can see that bootstrap is loaded after your css. So if you just add padding: 0 to your .container class it will be overrided by bootstrap's.

Try changing the order of stylesheets loading in your <head> so
yours is loaded last
.

Or just put a style attribute with padding: 0 directly to your container <div>, but that's not best practice.

Result:

No more padding

HTML table remove padding between specific columns

I have a different solution, and though slightly more complicated than the one previously suggested, I believe it will give you more flexibility as to how to apply the solution.

First, it does require some css code as shown below:

td:not([colspan='2']) {
/*your styling here*/
}
td[colspan='2'] {
display: table-row;
}
td[colspan='2'] > div {
display: table-cell;
width: 50%;
/*same styling here*/
}

Finally, the html:

<table>
<tbody>
<tr>
<td colspan='2'>
<div id="cell-a"></div>
<div id="cell-b"></div>
</td>
<td id="cell-c"></td>
<!--and so on-->

Basically, the css mimics the table's built-in display in order to optimize the table-row styling. This will allow css to do all the work, and furthermore, will allow you to put a colspan='2' anywhere in order to double up two cells wherever you need. I have already tested locally to ensure that this works.

Edit:
Just added the width: 50% under td[colspan='2'] > div in order to space them out properly within the table structure.

no padding on localhost but on webserver?

I think there is a mistake in padding-right pading-right:5px;

Plus the code you are using is fine, but some time it may happen that some pseudo will not work so better use directly while defining in CSS. like this..

    input[type="text"],input[type="password"] {
color: #ccc;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
width: 170px;
height: 20px;
line-height: 14px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-border-radius: 5px;
padding:3px 5px;
outline:none;
}

Try replacing with this code and reply if not wokring :)

Filling in padding bytes of a C struct in C++? (NOT concerning struct packing!)

You can just write a function like this:

template <class ... T>
constexpr foo_struct make_foo_struct(T ... t) {
return foo_struct{t..., 0};
}

static const auto foo = make_foo_struct(1, 2, 3);

You don't need to disable any warnings. As a bonus, if another field is added to the struct, the warning will come back (because you'll then have 5 members, and you're only initializing 4). This is also convenient because if you are creating lots of foos, and a new field is added that you don't care about (say it's a boolean, that you always want to be true), you can change make_foo_struct to initialize it the way you want, without modifying all of the call sites.

You can of course write out the types and argument names in make_foo_struct instead of using T...; it makes things more explicit but also requiring more maintenance and less flexible.

If the padding is removed, this should just fail to compile, and again you would only need to fix this one function. But if you don't like that, another option is to locally silence the warning with a compiler pragma, just in the function.

template <class ... T>
constexpr foo_struct make_foo_struct(T ... t) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
return foo_struct{t...};
#pragma GCC diagnostic pop
}

And to hell with it, I'll give a third option. If you there are 3 named members, and their names are stable, and you want to simply initialize them and zero out the rest, you can do:

constexpr foo_struct make_foo_struct(int x, int y, int z) {
foo_struct f{};
f.x = x; f.y = y; f.z = z;
return f;
}

The compiler should happily optimize this out.

Define padding member in C++

You can define it like that:

#define TOKENPASTE(x, y) x ## y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define PADDING(size) char TOKENPASTE2(padding_, __LINE__) [size]

Change field name prefix as you like it (preferably one that won't ever
collide with other possible members).

Keep in mind (as mentioned by Remy Lebeau and François Andrieux in comments) that compiler can sometimes add unexpected padding. For reference you can read:

  • Why isn't sizeof for a struct equal to the sum of sizeof of each member?
  • http://en.cppreference.com/w/cpp/language/data_members#Standard_layout

EDIT: Sorry, initial code was incorrect (it was incorrectly using __LINE__ expansion in macro). I fixed it using solution from: https://stackoverflow.com/a/1597129/1561140



Related Topics



Leave a reply



Submit