Issues With Child Elements of the DOM Respecting Parent Styling












0















The problem I'm having is regarding segmenting with divs in HTML. I have a parent div that has a border set for it with child divs placed within it (I'm creating a scoreboard for baseball as a test for nesting and layouts). However, despite the parent div containing the border, the children of the div elements are breaking out of the border as well as the divs themselves. Any ideas? Here's the HTML:



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial scale=1.0">
<link rel="stylesheet" href="BaseballScoreboard.css">
</head>
<body style="background-color:green;">

<div class="scoreboard">

<div>
<p id="atbat" class="text1">AT BAT</p>
<p id="atbatnum" class="num">12</p>
<p id="ball" class="text1">BALL</p>
<p id="ballnum" class="num">3</p>
<p id="strike" class="text1">STRIKE</p>
<p id="strikenum" class="num">2</p>
<p id="out" class="text1">OUT</p>
<p id="outnum" class="num">0</p>
</div>

<div>
<p id="inning" class="text2">INNING</p>
<p id="runs" class="text2">RUNS</p>
<p id="hits" class="text2">HITS</p>
<p id="errs" class="text2">ERRS</p>
</div>

<div>
<p id="visitor" class="text1">VISITOR</p>
<p id="home" class="text1">HOME</p>
</div>

</div>

</body>
</html>


...and here's the CSS:



.scoreboard{
border: 5px solid;
border-color: white;
color: white;
height: 50%;
width: 100%;
}

.text1{
font-size: 50px;
float: left;
margin-left: 25px;
}

.text2{
font-size: 50px;
float: right;
margin-left: 25px;
}

.num{
font-size: 50px;
float: left;
margin-left: 15px;
background-color: black;
padding: 5px;

}


I appreciate the help.










share|improve this question

























  • In this case, you need to clear your floats. I would recommend looking into using grid or flexbox for this instead.

    – brouxhaha
    Nov 20 '18 at 18:20











  • I thought it was the floats after a bit of experimentation.

    – Andrew Ramshaw
    Nov 20 '18 at 18:28
















0















The problem I'm having is regarding segmenting with divs in HTML. I have a parent div that has a border set for it with child divs placed within it (I'm creating a scoreboard for baseball as a test for nesting and layouts). However, despite the parent div containing the border, the children of the div elements are breaking out of the border as well as the divs themselves. Any ideas? Here's the HTML:



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial scale=1.0">
<link rel="stylesheet" href="BaseballScoreboard.css">
</head>
<body style="background-color:green;">

<div class="scoreboard">

<div>
<p id="atbat" class="text1">AT BAT</p>
<p id="atbatnum" class="num">12</p>
<p id="ball" class="text1">BALL</p>
<p id="ballnum" class="num">3</p>
<p id="strike" class="text1">STRIKE</p>
<p id="strikenum" class="num">2</p>
<p id="out" class="text1">OUT</p>
<p id="outnum" class="num">0</p>
</div>

<div>
<p id="inning" class="text2">INNING</p>
<p id="runs" class="text2">RUNS</p>
<p id="hits" class="text2">HITS</p>
<p id="errs" class="text2">ERRS</p>
</div>

<div>
<p id="visitor" class="text1">VISITOR</p>
<p id="home" class="text1">HOME</p>
</div>

</div>

</body>
</html>


...and here's the CSS:



.scoreboard{
border: 5px solid;
border-color: white;
color: white;
height: 50%;
width: 100%;
}

.text1{
font-size: 50px;
float: left;
margin-left: 25px;
}

.text2{
font-size: 50px;
float: right;
margin-left: 25px;
}

.num{
font-size: 50px;
float: left;
margin-left: 15px;
background-color: black;
padding: 5px;

}


I appreciate the help.










share|improve this question

























  • In this case, you need to clear your floats. I would recommend looking into using grid or flexbox for this instead.

    – brouxhaha
    Nov 20 '18 at 18:20











  • I thought it was the floats after a bit of experimentation.

    – Andrew Ramshaw
    Nov 20 '18 at 18:28














0












0








0








The problem I'm having is regarding segmenting with divs in HTML. I have a parent div that has a border set for it with child divs placed within it (I'm creating a scoreboard for baseball as a test for nesting and layouts). However, despite the parent div containing the border, the children of the div elements are breaking out of the border as well as the divs themselves. Any ideas? Here's the HTML:



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial scale=1.0">
<link rel="stylesheet" href="BaseballScoreboard.css">
</head>
<body style="background-color:green;">

<div class="scoreboard">

<div>
<p id="atbat" class="text1">AT BAT</p>
<p id="atbatnum" class="num">12</p>
<p id="ball" class="text1">BALL</p>
<p id="ballnum" class="num">3</p>
<p id="strike" class="text1">STRIKE</p>
<p id="strikenum" class="num">2</p>
<p id="out" class="text1">OUT</p>
<p id="outnum" class="num">0</p>
</div>

<div>
<p id="inning" class="text2">INNING</p>
<p id="runs" class="text2">RUNS</p>
<p id="hits" class="text2">HITS</p>
<p id="errs" class="text2">ERRS</p>
</div>

<div>
<p id="visitor" class="text1">VISITOR</p>
<p id="home" class="text1">HOME</p>
</div>

</div>

</body>
</html>


...and here's the CSS:



.scoreboard{
border: 5px solid;
border-color: white;
color: white;
height: 50%;
width: 100%;
}

.text1{
font-size: 50px;
float: left;
margin-left: 25px;
}

.text2{
font-size: 50px;
float: right;
margin-left: 25px;
}

.num{
font-size: 50px;
float: left;
margin-left: 15px;
background-color: black;
padding: 5px;

}


I appreciate the help.










share|improve this question
















The problem I'm having is regarding segmenting with divs in HTML. I have a parent div that has a border set for it with child divs placed within it (I'm creating a scoreboard for baseball as a test for nesting and layouts). However, despite the parent div containing the border, the children of the div elements are breaking out of the border as well as the divs themselves. Any ideas? Here's the HTML:



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial scale=1.0">
<link rel="stylesheet" href="BaseballScoreboard.css">
</head>
<body style="background-color:green;">

<div class="scoreboard">

<div>
<p id="atbat" class="text1">AT BAT</p>
<p id="atbatnum" class="num">12</p>
<p id="ball" class="text1">BALL</p>
<p id="ballnum" class="num">3</p>
<p id="strike" class="text1">STRIKE</p>
<p id="strikenum" class="num">2</p>
<p id="out" class="text1">OUT</p>
<p id="outnum" class="num">0</p>
</div>

<div>
<p id="inning" class="text2">INNING</p>
<p id="runs" class="text2">RUNS</p>
<p id="hits" class="text2">HITS</p>
<p id="errs" class="text2">ERRS</p>
</div>

<div>
<p id="visitor" class="text1">VISITOR</p>
<p id="home" class="text1">HOME</p>
</div>

</div>

</body>
</html>


...and here's the CSS:



.scoreboard{
border: 5px solid;
border-color: white;
color: white;
height: 50%;
width: 100%;
}

.text1{
font-size: 50px;
float: left;
margin-left: 25px;
}

.text2{
font-size: 50px;
float: right;
margin-left: 25px;
}

.num{
font-size: 50px;
float: left;
margin-left: 15px;
background-color: black;
padding: 5px;

}


I appreciate the help.







html css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 18:26







Andrew Ramshaw

















asked Nov 20 '18 at 18:16









Andrew RamshawAndrew Ramshaw

436




436













  • In this case, you need to clear your floats. I would recommend looking into using grid or flexbox for this instead.

    – brouxhaha
    Nov 20 '18 at 18:20











  • I thought it was the floats after a bit of experimentation.

    – Andrew Ramshaw
    Nov 20 '18 at 18:28



















  • In this case, you need to clear your floats. I would recommend looking into using grid or flexbox for this instead.

    – brouxhaha
    Nov 20 '18 at 18:20











  • I thought it was the floats after a bit of experimentation.

    – Andrew Ramshaw
    Nov 20 '18 at 18:28

















In this case, you need to clear your floats. I would recommend looking into using grid or flexbox for this instead.

– brouxhaha
Nov 20 '18 at 18:20





In this case, you need to clear your floats. I would recommend looking into using grid or flexbox for this instead.

– brouxhaha
Nov 20 '18 at 18:20













I thought it was the floats after a bit of experimentation.

– Andrew Ramshaw
Nov 20 '18 at 18:28





I thought it was the floats after a bit of experimentation.

– Andrew Ramshaw
Nov 20 '18 at 18:28












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399127%2fissues-with-child-elements-of-the-dom-respecting-parent-styling%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399127%2fissues-with-child-elements-of-the-dom-respecting-parent-styling%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)