需要帮助将图像添加到响应式布局

Posted

技术标签:

【中文标题】需要帮助将图像添加到响应式布局【英文标题】:Need help adding images to responsive layout 【发布时间】:2016-09-09 17:44:23 【问题描述】:

我正在使用 bootstrap 3 制作一个响应式网站,而我才刚刚开始使用它,所以我还没有真正掌握它的窍门。我在一个容器内制作了 2 列。在第一列中,我有一个导航栏/图像,在第二列中,我有文本。我正在尝试在我拥有的导航栏/图像下添加 3 个图像(在 div 中),但是当我尝试执行此操作时,div 显示但右列移动到它应该在移动设备上显示的内容。我认为我的媒体查询可以做到这一点,但我不确定如何解决它。 This 是我希望它的外观和响应能力,this 是我尝试实现图像时发生的情况。

/*style sheet*/


#Backg

background-image: url("Graphics/ravenna.png");
background-repeat: repeat;
height: 100%;



/*Biggest Container and Pattern Backg*/
#PrimaryC 
padding: 10px;
background-image: url("Graphics/paper_fibers.png");
background-repeat: repeat;
height: 100%;
-moz-box-shadow: 0px 0px 20px #000000;
-webkit-box-shadow: 0px 0px 20px #000000;
box-shadow: 0px 0px 20px #000000;


#Header /*Retro Games Arcade Logo*/

height: 100px;
width: 100%;
background-image: url("Graphics/SiteLogo.png");
background-repeat: no-repeat;
background-size: 100% 100%;
background-position: center;
  

.Content /*Holds Arcade Photo and Text in 2 columns*/

width: 100%;
background-color: white;
resize: both;
border-radius: 0px 25px 25px 25px;
border: 1px solid white;


#HeaderText /*Title*/

font-family:'Rokkitt', serif;
font-size: 35px;
color: black;
text-decoration: underline;
padding-right: 20px;


#RegularText /*Main Text Body*/



font-family:'Rokkitt', serif;
font-size: 18px;
padding-right: 20px;


.dropcap
 float: left;
 color: #903;
 font-size: 75px;
 line-height: 60px;
 padding-top: 4px;
 padding-right: 8px;
 padding-left: 3px;
 font-family: Georgia; 
 


#Arcade /*Arcade Photo*/

width: 100%;



/*Navigational Buttons*/
.post-content

font-family:'Didact Gothic', sans-serif;
font-size: 150%; /*20px*/
top: 120px;
left:15px;
position: relative;
 letter-spacing: 2px;



#RightRow

Position: relative;


.centerBlock

position: relative;
top: -200px;
padding-left: 10px;


.img-responsive.gallery

float: left;
width: 158px;
height: 162px;
margin-right: 25px;






158, 162

.col-md-12 

position: relative;





.footer-basic-centered
	background-color: #292c2f;
	box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
	box-sizing: border-box;
	width: 100%;
	text-align: center;
	font: normal 18px sans-serif;

	padding: 15px;
	margin-top: 80px;


.footer-basic-centered .footer-company-motto
	color:  #8d9093;
	font-size: 24px;
	margin: 0;


.footer-basic-centered .footer-company-name
	color:  #8f9296;
	font-size: 14px;
	margin: 0;


.footer-basic-centered .footer-links
	list-style: none;
	font-weight: bold;
	color:  #ffffff;
	padding: 35px 0 23px;
	margin: 0;


.footer-basic-centered .footer-links a
	display:inline-block;
	text-decoration: none;
	color: inherit;




@media (max-width: 600px) 

	.footer-basic-centered
		padding: 35px;
	

	.footer-basic-centered .footer-company-motto
		font-size: 18px;
	

	.footer-basic-centered .footer-company-name
		font-size: 12px;
	

	.footer-basic-centered .footer-links
		font-size: 14px;
		padding: 25px 0 20px;
	

	.footer-basic-centered .footer-links a
		line-height: 1.8;
	



/*Desktop*/
#Home, #Stock, #AboutUs, #ContactUs

padding-bottom: 22px;
position: relative;
top: -360px;




/*Tablet Devices*/
@media (min-width: 768px) and (max-width: 969px) 
#Home, #Stock, #AboutUs, #ContactUs

padding-bottom: 18px;
position: relative;
top: -270px;
font-size: 50%;




/*Mobile Devices*/
@media(max-width: 767px) 
#Home, #Stock, #AboutUs, #ContactUs

padding-bottom: 18px;
position: relative;
font-size: 20%;
top: auto;
 
.post-content

top: 20px;
font-size: 80px;


/*1200*/
@media (min-width: 970px) and (max-width: 1119px) 
#Home, #Stock, #AboutUs, #ContactUs

padding-bottom: 25px;
position: relative;
top: -310px;
font-size: 60%;

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<!DOCTYPE html>
<html>
  <head>
    <meta name="generator"
    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="Styles.css" />
    <!--Main Style Sheet-->
    <link rel="stylesheet" href="bootstrap.min.css" />
    <!--Bootstrap Style Sheet-->
    <link href='https://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css' />
    <!--Permanent Marker Font-->
    <link href='https://fonts.googleapis.com/css?family=Press+Start+2P' rel='stylesheet' type='text/css' />
    <!--Press Start 2P Font-->
    <link href='https://fonts.googleapis.com/css?family=Rokkitt' rel='stylesheet' type='text/css' />
    <link href='https://fonts.googleapis.com/css?family=Didact+Gothic' rel='stylesheet' type='text/css' />
    <title>Retro Games Arcade</title>
  </head>
  <body>
    <div id="Backg">
      <div id="PrimaryC" class="container">
        <!--Primary Container-->
        <div id="Header">
          <!--Site Logo-->
        </div>
        <div class="Content">
          <!--Main Content Container-->
          <div class="row">
            <!--Row 1-->
            <div class="col-sm-6">
              <!--Left Col-->
              <img src="Graphics/Arcade.png" id="Arcade" class="hidden-xs" />
              <div class="caption post-content">
                <div id="Home">home</div>
                <!--Home Button-->
                <div id="Stock">stock</div>
                <!--Stock Button-->
                <div id="AboutUs">about us</div>
                <!--About Us Button-->
                <div id="ContactUs">contact us</div>
                <!--Contact Us Button-->
              </div>
			<div class="centerBlock">
			  <div><img class="img-responsive gallery" src="Graphics/">
			  </div>
			  <div><img class="img-responsive gallery" src="Graphics/">
			  </div>
			  <div><img class="img-responsive gallery" src="Graphics/">
			  </div>
            </div>
            <div class="col-sm-6" id="RightRow">
              <!--RightCol-->
              <p id="HeaderText">Welcome to the Retro Games Arcade</p>
              <p id="RegularText">
              <span class="dropcap">H</span>ere you can find a treasure of Retro Video Games, sell your unwanted hardware/software;
              and also have our professional team repair any damaged hand-held gaming devices.
              <br />
              <br />We have one of the biggest collectecions of Retro Video Games in the UK, and have genres ranging from Puzzle
              Games and Platformers, to Roleplaying Games and Stratgey Games.
              <br />
              <br />Our staff have over 100 years combined experience of playing retro video games and a professional certified
              Nintendo technician, so if you want a recommendation for your
              <br />sons birthday present, or you need to get your old GameCube repaired; we are your guys.</p>
            </div>
          </div>
        </div>
        <div class="row">
          <!--Row 2-->
          <div class="col-md-12">
            <img src="Graphics/Aracde3.png" id="Vector" class="img-responsive center-block" class="hidden-xs" />
          </div>
        </div>
        <footer class="footer-basic-centered">
          <p class="footer-company-motto">Expand Your Retro Playground.</p>
          <p class="footer-links">
          <a href="#">Home</a> · 
          <a href="#">Stock</a> · 
          <a href="#">About Us</a> · 
          <a href="#">Contact Us</a></p>
          <p class="footer-company-name">Retro Games Arcade ɠ2015</p>
        </footer>
      </div>
    </div>
  </body>
</html>

感谢任何帮助!如果需要任何其他信息,我也很乐意提供帮助。

【问题讨论】:

【参考方案1】:

右列包含在页面的左侧,因为它是 class="col-sm-6" 在它之前的 class="col-sm-6" 内。

您在&lt;div class="col-sm-6" id="RightRow"&gt; 之前似乎缺少&lt;/div&gt;

【讨论】:

啊,我还以为会是这样的傻事呢,谢谢你的帮助!

以上是关于需要帮助将图像添加到响应式布局的主要内容,如果未能解决你的问题,请参考以下文章

响应式文本框布局

一行css代码搞定响应式布局

一行 CSS 代码实现响应式布局 – 使用 Grid 实现的响应式布局

具有浮动和全宽布局的响应式图像

grid实现响应式布局

没有预定义宽度的响应式砌体布局