参见英文答案 Extend bootstrap row outside the container4个 我需要编写下一个示例代码: 我正在使用bootstrap对所有网站进行编码,本节的代码如下: `div class="bg_blue" div class="container" !-- Example ro
我需要编写下一个示例代码:
我正在使用bootstrap对所有网站进行编码,本节的代码如下:
`<div class="bg_blue"> <div class="container"> <!-- Example row of columns --> <div class="row"> <div class="col-md-6"> <div id="login-form-box" class="form-box"> <div id="login-form-info" class="form-info"> <?php if (isset($content['info']) && !empty($content['info'])) { echo $content['info']; } ?> </div> <?php if (isset($error_message)) { echo '<div id="login-form-info" class="form-error">'.$error_message.'</div>'; } ?> <form id="login-form" class="form" action="<?php echo api_get_path(WEB_PATH)?>index.php" method="post"> <div> <label for="login"><?php echo custompages_get_lang('User');?></label> <input name="login" type="text" /><br /> <label for="password"><?php echo custompages_get_lang('Password');?></label> <input name="password" type="password" /><br /> </div> </form> <div id="login-form-submit" class="form-submit" onclick="document.forms['login-form'].submit();"> <span><?php echo custompages_get_lang('LoginEnter');?></span> </div> <!-- #form-submit --> <div id="links"> <?php if (api_get_setting('allow_registration') === 'true') { ?> <a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/inscription.php?language=<?php echo api_get_interface_language(); ?>"> <?php echo custompages_get_lang('Registration')?> </a><br /> <?php } ?> <a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/lostPassword.php?language=<?php echo api_get_interface_language(); ?>"> <?php echo custompages_get_lang('LostPassword')?> </a> </div> </div> </div> <div class="col-md-6"> <!-- <img class="img" src="<?php echo api_get_path(WEB_PATH)?>/custompages/images/bgimage.png" alt="Background" /> --> </div> </div> <!-- /row --> </div><!-- /container --> </div>`
问题是我无法将图像背景设置为第二列调整大小,并且覆盖了整个列,而不是右边的列-md-6.
这是一个小草图:
如果您只想以中等屏幕尺寸为目标,可以按以下方式进行.给你的img元素宽度:120%,它会溢出并在左边取整个尺寸.工作片段
.img { width: 120%; } .col-md-6 { background-color: green; }
<html> <head> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="http://img.558idc.com/uploadfile/allimg/210612/1106142604-6.jpg"></script> </head> <body> <div class="bg_blue"> <div class="container"> <!-- Example row of columns --> <div class="row"> <div class="col-md-6"> <div id="login-form-box" class="form-box"> <div id="login-form-info" class="form-info"> </div> <form id="login-form" class="form" action="" method="post"> <div> <label for="login"></label> <input name="login" type="text" /><br /> <label for="password"></label> <input name="password" type="password" /><br /> </div> </form> <div id="login-form-submit" class="form-submit" onclick="document.forms['login-form'].submit();"> <span></span> </div> <!-- #form-submit --> <div id="links"> <a href=""> </a><br /> <a href=""> </a> </div> </div> </div> <div class="col-md-6"> <img class="img" src="https://www.w3schools.com/css/trolltunga.jpg" alt="Background" /> </div> </div> <!-- /row --> </div> <!-- /container --> </div> </body> </html>
注意:
如果您想要定位所有屏幕尺寸的媒体,那么只需使用col-lg- * col-xs- * col-sm- *即不同的响应式引导类.
希望这可以帮助!