DEVHIDE
  • Home (current)
  • About
  • Contact
  • Cookie
  • Home (current)
  • About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy
  • TOS
Login Or Sign up

How to margin div inside other div?

1.8k Views Asked by Ruslan Lomov At 23 June 2015 at 14:50 2025-12-19T16:52:44.069425

html body,simple form with table and two divs inside(login and table):

<body>
    <div id="container">
        <form>
            <div class="login">
                <div class="table">
                    <table class="userInput">
                        <tr>
                            <td><input type="text" placeholder="Username" id="username"
                                name="login"></td>
                        </tr>
                        <tr>
                            <td><input type="submit" value="submit"></td>
                        </tr>
                    </table>
                </div>
            </div>
        </form>
    </div>
</body>

My css:

html,body {
    margin: 0;
    padding: 0;
    height: 100%;
}

table.userInput {
    margin-top: 15%;
    width: 100%;
    height: 100%;
}

div#container {
    background: pink;
    height: 100%;
}

div.login {
    background-color: black;
    margin-top: 15%;
    margin-left: auto;
    margin-right: auto;
    height: 10%;
    width: 10%;
    padding: 10px;
}

div.table {
    width: 100%;
    height: 100%;
    background-color: grey;
}

Need my div class="table" after margin-top:15% of table class="userInput" visible with grey background but after offset i can see black color of login div class="login". How to make it grey with margin-top?enter image description here

html css styling
Original Q&A
2

There are 2 best solutions below

1
Raźnyy Raźnyy On 23 June 2015 at 15:13 BEST ANSWER

If i understand your question well i suggest you to change

padding:10px;

to

padding-top:10px;

and increase width of <div class='login'> element

EDIT

Your image change almost everything , please check this fiddle : SOLUTION

Only thing i change is remove margin-top:15%; and replace it with padding-top:15%; so i can add background-color:grey; to table.userInput element.

Looks like in your image. Let me know if it helps :)

3
AndrewH AndrewH On 23 June 2015 at 15:10

Change margin-top: 15%; to padding-top: 15%;

table.userInput {
    padding-top: 15%;
    width: 100%;
    height: 100%;
}

Based on your picture I think this is what you want.

top padding

http://jsfiddle.net/7j8z3v3w/

Related Questions in HTML

  • Delay in loading Html Page(WebView) from assets folder in real android device
  • Why does a function show up as not defined
  • CSS Class is not applying to element (border width,color,and style attributes)
  • How to sort these using Javascript or Jquery Most effectively
  • how to fill out the table with next values in array with one button
  • Automatically closing tags in form input?
  • Positioning child at bottom of parent with scroll
  • Remove added set of rows
  • Website zoomed out on Android default browser
  • Twitter Bootstrap horizontal form elements on a line
  • http://sigmajs.org/ les mis tutorial - why are my canvases 0 height?
  • My navbar is not expanding after collapse
  • when a checkbox is checked how to display a different hidden element using javascript
  • Gaps Vertically Using Dividers
  • Svg containers not positioning properly

Related Questions in CSS

  • CSS Class is not applying to element (border width,color,and style attributes)
  • How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?
  • Positioning child at bottom of parent with scroll
  • Play multiple audio files in a slider
  • How to set text over image?
  • Website zoomed out on Android default browser
  • Writing/Overwriting to specific XML file from ASP.NET code behind
  • My navbar is not expanding after collapse
  • when a checkbox is checked how to display a different hidden element using javascript
  • Gaps Vertically Using Dividers
  • CSS: Preventing a property to affect on element until the end of transition
  • Polygon Button with pure CSS
  • transform-origin doesnt apply in safari
  • show/hide multiple div tags at once and change the size of the remaining div tag
  • Mask the image/maps/div (circle) using css and jquery

Related Questions in STYLING

  • Change background color of tabBar in v4 viewPager
  • How do I apply styling to sorted columns in Angular ui-grid?
  • styling figure & figcaption
  • Can the jquery dataTables plugin respect alternate row colors after sorting/filtering?
  • Enumerate and apply WPF styles programmatically
  • Custom Cursor using CSS styling - html/css - javascript
  • Getting an "arrowed" bottom on a div
  • Polymer 1.0 styling not working
  • Is there any way to increment a CSS value depending on nth-child variable?
  • QCalendar styling. Attribute for disabled items
  • How to edit a sprite gif image in eclipse
  • CSS behavior is changing between chrome and firefox
  • How to margin div inside other div?
  • How to style td with input button and text-size button?
  • Horizontal Line Styling on Each Side of Titles

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

Popular # Hahtags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?
.

Copyright © 2021 Jogjafile Inc.

  • Disclaimer
  • Privacy
  • TOS
  • Homegardensmart
  • Math
  • Aftereffectstemplates