Questions tagged [margin]

The CSS margin properties define the space around elements.

CSS

3723 questions
72
votes
4 answers

CSS display: inline-block does not accept margin-top?

I have an element with display: inline-block, but it doesn't seem to accept margin-top. Is this because the element is still treated as an inline element? If yes, does anyone have a workaround? EDIT #1: My CSS is quite simple: .label { …
Gregory Bolkenstijn
  • 10,003
  • 7
  • 36
  • 38
72
votes
6 answers

How do I extend the margin at the bottom of a figure in Matplotlib?

The following screenshot shows my x-axis. I added some labels and rotated them by 90 degrees in order to better read them. However, pyplot truncates the bottom such that I'm not able to completely read the labels. How do I extend the bottom…
toom
  • 12,864
  • 27
  • 89
  • 128
65
votes
5 answers

UITableViewCell with autolayout left margin different on iPhone and iPad

I am using a grouped UITableView with static cells for an options screen/scene. Everything is done in Xcode 6.1 / iOS 8.1.x / Storyboard using Autolayout. Within the table groups there are mixed types of cells and there are two types that cause me…
The Lone Coder
  • 3,062
  • 4
  • 20
  • 35
64
votes
5 answers

CSS: background-color only inside the margin

I have searched for an answer but couldn't find it anywhere. My question is reasonably simple: I have a background color of my body, then a large margin, and now I want a different background color inside the margin. How do I do that with CSS?
user1318194
63
votes
4 answers

How wide is the default `` margin?

What’s the default margin that HTML sets for its tag? I noticed that there’s some automatic margin, but I’m wondering if anyone knows how much it is (and whether it’s in px or %, etc.).
John
  • 4,596
  • 11
  • 37
  • 43
62
votes
7 answers

Binding only part of the margin property of WPF control

I have this: ... I want to bind only the "Top" part of the TabControl, which intuitively I would do it this way:
Tar
  • 8,529
  • 9
  • 56
  • 127
57
votes
11 answers

How to set margin for a Button in Flutter

I am just creating a form in Flutter. I am not able to set the top margin for the button. class _MyHomePageState extends State { String firstname; String lastname; final scaffoldKey = new GlobalKey(); final formKey = new…
Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56
56
votes
10 answers

Removing body margin in CSS

I'm new to web development, and met a problem when removing margin of body. There's space between the very top of the browser and "logo" text. And my code is here on jsbin. Is body { margin: 0;} wrong if I'd like to remove the space?
chenghuayang
  • 1,424
  • 1
  • 17
  • 35
55
votes
5 answers

Why doesn't "margin: auto" center an element vertically?

As you can see in the demo below, margin: auto; centers the blue div horizontally, but not vertically. Why not? .box { border: 1px solid red; width: 100px; height: 100px; } .center { background: blue; width: 50px; height:…
Stickers
  • 75,527
  • 23
  • 147
  • 186
55
votes
7 answers

CSS: Margin-top when parent's got no border

As you can see in this picture, I've got an orange div inside a green div with no top border. The orange div has a 30px top margin, but it's also pushing the green div down. Of course, adding a top border will fix the issue, but I need the green div…
Manny
  • 553
  • 1
  • 4
  • 4
54
votes
1 answer

Why would margin not be contained by parent element?

When an element with a margin is contained within another element, the parent does not consistently wrap/contain that margin. Many things will cause the parent to contain the child's margin: border: solid; position: absolute; display:…
SamGoody
  • 13,758
  • 9
  • 81
  • 91
52
votes
1 answer

margin inside the edit text in android

My question is : I have an EditText and I want set a margin inside the EditText, I mean margin for the content (the text) of the edit text, not a margin for a the view witch I can resolve by this attribute : android:layout_marginLeft. I need let…
Alaoui Ghita
  • 1,859
  • 4
  • 22
  • 26
52
votes
7 answers

How to remove margin space around body or clear default css styles

I am admittedly a beginner, but I also did a fair amount of searching before posting this. There seems to be extra space around my div element. I also would like to point out that I tried many combinations of border: 0, padding:0, etc. and nothing…
Anthony
  • 1,760
  • 1
  • 23
  • 43
52
votes
3 answers

CSS Right Margin Does Not Work Inside a Div With Overflow Scroll

I am trying to make two divs, one inside the other. The inner div is larger than the outer div, the outer div has overflow:scroll, and the inner div has margin:25px. So I do this: #outer { width: 200px; height: 100px; overflow:…
Sean the Bean
  • 5,222
  • 5
  • 38
  • 40
51
votes
10 answers

Set position absolute and margin

I would like to set an element's position to absolute and have a margin-bottom, but it seems that the margin-bottom doesn't have an effect. HTML:
CSS: #container { border: 1px solid red; position: absolute; top:…
kirby
  • 3,981
  • 14
  • 41
  • 54