Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 我如何解决这个css问题?_Html_Css - Fatal编程技术网

Html 我如何解决这个css问题?

Html 我如何解决这个css问题?,html,css,Html,Css,我想在一些html元素周围放一个框。但是,此代码会导致每个单独的元素。我不想使用html或body元素,因为我有其他我想要在框外的元素 h1, p { width: 300px; padding: 50px; border: 20px solid #0088dd; text-align: center;} </style>

我想在一些html元素周围放一个框。但是,此代码会导致每个单独的元素。我不想使用html或body元素,因为我有其他我想要在框外的元素

h1, p {
                width: 300px;
                padding: 50px;
                border: 20px solid #0088dd;
                text-align: center;}

        </style>
        </head>
        <body>
            <p>this should be in the box</p>
            <h1>this should be in the box</h1>
            <h2> this should not be in the box</h2>
h1,p{
宽度:300px;
填充:50px;
边框:20px实心#0088dd;
文本对齐:居中;}
这个应该在盒子里

这个应该在盒子里 这个不应该在盒子里
您需要一个周围的元素来连接boder。在这种情况下,可以在样式中使用主体,如下所示

<style type="text/css">
body {
            width: 300px;
            padding: 50px;
            border: 20px solid #0088dd;
            text-align: center;}

</style>

身体{
宽度:300px;
填充:50px;
边框:20px实心#0088dd;
文本对齐:居中;}
警告:在body标签上添加边框不会出现在任何最佳实践列表中。永远

正确的方法是只使用一个类

   <style type="text/css">
    .boxme {
                width: 300px;
                padding: 50px;
                border: 20px solid #0088dd;
                text-align: center;}

    </style>
</header>
<body>
    <div class="boxme">
        <p>lol</p>
        <h1>Thanks for helping</h1>
    </div>
    <p>Other text</p>

boxme先生{
宽度:300px;
填充:50px;
边框:20px实心#0088dd;
文本对齐:居中;}
哈哈

谢谢你的帮助 其他文本


您需要一个周围的元素来连接boder。在这种情况下,可以在样式中使用主体,如下所示

<style type="text/css">
body {
            width: 300px;
            padding: 50px;
            border: 20px solid #0088dd;
            text-align: center;}

</style>

身体{
宽度:300px;
填充:50px;
边框:20px实心#0088dd;
文本对齐:居中;}
警告:在body标签上添加边框不会出现在任何最佳实践列表中。永远

正确的方法是只使用一个类

   <style type="text/css">
    .boxme {
                width: 300px;
                padding: 50px;
                border: 20px solid #0088dd;
                text-align: center;}

    </style>
</header>
<body>
    <div class="boxme">
        <p>lol</p>
        <h1>Thanks for helping</h1>
    </div>
    <p>Other text</p>

boxme先生{
宽度:300px;
填充:50px;
边框:20px实心#0088dd;
文本对齐:居中;}
哈哈

谢谢你的帮助 其他文本


试着做这样的事情

 <div class="border-csl">
       <p>lol</p>
       <h1>Thanks for helping</h1>
  </div>

.border-csl {
        width: 300px;
        padding: 50px;
        border: 20px solid #0088dd;
        text-align: center;
 }

哈哈

谢谢你的帮助 B.边界csl{ 宽度:300px; 填充:50px; 边框:20px实心#0088dd; 文本对齐:居中; }
尝试这样做

 <div class="border-csl">
       <p>lol</p>
       <h1>Thanks for helping</h1>
  </div>

.border-csl {
        width: 300px;
        padding: 50px;
        border: 20px solid #0088dd;
        text-align: center;
 }

哈哈

谢谢你的帮助 B.边界csl{ 宽度:300px; 填充:50px; 边框:20px实心#0088dd; 文本对齐:居中; }
还有其他方法吗。我不想使用html或body作为css元素,因为我还有其他我想要的元素在框外。有没有其他方法可以做到这一点。我不想使用html或body作为css元素,因为我在框外还有其他我想要的元素。你真正需要什么?你真正需要什么?