css 类无法正常工作

了解更多

我正在重新设计我的网站。这样做我发现自己在使用我编写的 css 代码时遇到了一些问题。

我使用 div 来获取图像和一些彼此相邻的文本。我无法将文本移动到正确的位置(见图片)当它在 css 文件中时,左边距似乎不起作用,但是当它直接嵌入到 div 标签中时它起作用,我做错了什么?

我还想补充一点,我不需要在 html 代码中设置图像大小,但它在 css 代码中这可能吗?

我得到了什么

我得到了什么

我想要的是

我想要的是

body
{
	background:#333 url(bg.jpg) repeat top left;
	font-family:Arial;
	color:white;
	text-align:center;
}

body header.heading
{
	width:1150px;
	/*background:transparent url(../images/menu/MEbanner.jpg) no-repeat top;
	background-size: 1150 100px;
	padding-top:101px;*/
	margin:0 auto;
	z-index:0;
	
}


body.Content
{
	width:1150px;
}

main
{
width:1150px;
	margin: 0 auto;
}

section 
{
	text-align:left;
	margin:0 auto;
}

header nav
{
	width:1150px;
	background:transparent url(../images/menu/MEbanner.jpg) no-repeat top;
	background-size: 1150 100px;
	padding-top:101px;
	margin:0 auto;
	z-index:0;
}

header nav ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}

header nav li {
    float: left;
    border-right: 1px solid #bbb;
}

header nav li:last-child {
    border-right: none;
}

/*header nav li a {
    display: block;
    color: white;
    text-align: center;
    padding: 20px 16px;
    text-decoration: none;
}*/

/* Change the link color to #111 (black) on hover */
header nav li a:hover {
    background-color: #111;
}

header nav li.active {
    background-color: #4CAF50;
}

header nav li a, .dropbtn {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 20px 16px;
    text-decoration: none;
}

header nav li a:hover, .dropdown:hover .dropbtn {
    background-color:  #111;
}

header nav li.dropdown {
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
    display: block;
}

nav 
{
	text-align:left;
	margin:0 auto;
}

.hidden {display:none}

hr
{	
	border-left: none;
	border-right: none;
	height:4px;
	margin: 2em 0 2em 0;
}

main a:link {color:#fff;}      /* unvisited link */

main a:visited {color:#fff;}  /* visited link */

main a:hover {color:#159;}  /* mouse over link */

blockquote{
	color:white;	
	border-left: 8px solid;
	border-color: #0BD676;/*#0DFF8C;*/
	padding-left:10px;
}

h2
{
	font-size: 30px;
	color:Black;
}

h1,h2,h3,h4
{
	font-family: 'Open Sans Condensed', sans-serif;
	color:#4CAF50;
	text-decoration:underline;
}

h2, h3
{
	font-size: 1.6em;
	letter-spacing: -1px;
	margin: 0 0 0.75em 0;
}

h3
{
	font-size:1.3em;
}

h1
{
	font:bold;
}



h4
{
	font-size:1em;
	margin: 0.5em 0 0.5em;
	padding-left:1em;
}

.green
{
	border-left: 8px solid;
	border-color: #0BD676;/*#0DFF8C;*/
	padding-left:10px;
	color: #4CAF50;
	margin-left:40px;
	font-style:oblique;
}

article.centeralign
{
	text-align:center;
}

div.wrapper{
	width: 800px;
	overflow: hidden;
}

div.toolsWrapper{
	width: 980px;
	overflow: hidden;
}

div.left{
    width: 200px;
    float:left;
    margin-right:40px;
    padding-left:40px;
}

div.right{
    float:left;
    margin-left: 20px;
}


div.cc
	{
		width:200px;
		text-align:right;
		font-size:10px;
	}
	
div.ccf
	{
		text-align:center;
		font-size:12px;
	}

iframe
{
	text-align:center;
	float:center;
}

/* ===========================
   ====== Contact Form ======= 
   =========================== */

input, textarea {
	padding: 10px;
	border: 1px solid #E5E5E5;
	width: 200px;
	color: #999999;
	box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
	-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
	-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;		
}

textarea {
	width: 400px;
	height: 150px;
	max-width: 400px;
	line-height: 18px;
}

input:hover, textarea:hover,
input:focus, textarea:focus {
	border-color: 1px solid #C9C9C9;
	box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 8px;
	-moz-box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 8px;
	-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 8px;	
}

.form label {
	margin-left: 10px;
	color: #999999;
}

/* ===========================
   ====== Submit Button ====== 
   =========================== */

.submit input {
	width: 100px; 
	height: 40px;
	background-color: #474E69; 
	color: #FFF;
	border-radius: 3px;
	-moz-border-radius: 3px;
	-webkit-border-radius: 3px;		
}

table, th, td {
    border: 1px solid black;
    border-color:white;
}

th, td {
    padding: 15px;
}

.blue{
		background: url(blue.png) no-repeat left center;
  		color: #109CEF;
  		padding: 0px 40px 0px 20px;
		font-style:oblique;
	}



.red{
		background: url(red.png) no-repeat left center;
		color:#FF0000;
		padding: 0px 40px 0px 20px;
		font-style:oblique;
}
<article>
  <h1>Audio Projects</h1>
    <blockquote>
     <h3>
          <a href="Damp">
              Class D Amplifier
          </a>
      </h3>
      <div class="wrapper">
          <div class="left">
              <img src="Damp/Damp_front.JPG"/>
          </div>
          <div class="right">
              Some text that should be next to image                          
          </div>
      </div>
  </blockquote>
</article>

詹姆斯·道格拉斯

您只需要更改一些样式,并将其替换<article><div>(对于 IE 支持)

div.wrapper {
  width: 800px;
  overflow: hidden;
}
div.toolsWrapper {
  width: 980px;
  overflow: hidden;
}
div.left {
  width: 200px;
  float: left;
  margin-right: 40px;
  padding-left: 40px;
}
div.right {
  color: white;
  display: inline-block;
  position: absolute;
  top: 0;
}
.wrapper {
  position: relative;
  width: 50%;
}
.title {
  color: #4B9F49;
}
.inner_title {
  color: white;
}
.blockquote {
  border-left: 3px solid #0CD673;
  padding-left: 5px;
}
#article {
  background: black;
}
<div id="article">
  <h3>
    <a href="Damp" class="title">Audio Projects</a>
  </h3>
  <blockquote class="blockquote">
    <h3>
      <a href="Damp" class="inner_title">Class D Amplifier</a>
    </h3>
    <div class="wrapper">
      <img src="Damp/Damp_front.JPG" style="height:80px; width:200px;"/>
      <div class="right">
        Some text that is now next to the image. 
      </div>
    </div>
  </blockquote>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章