当我把窗户缩小时,字母会从按钮上切断

时间:2017-10-12 21:46:33

标签: css button

每当我把窗户缩小时,我的按钮上的字母就会被切断。我不确定如何实施解决方案。我提供了css和html。我还提供了图片以便更好地理解。 我知道我必须在css中更改或添加一些内容,但我不确定是什么。

我不确定如何实施解决方案。我提供了css和html。我还提供了图片以便更好地理解。

enter image description here

.button {
	display: inline-block;
	position: relative;
	cursor: pointer;
	outline: none;
	white-space: nowrap;
//	margin: 5px;
	padding: 0 22px;
	font-size: 14px;
	font-family: 'Roboto', sans-serif, 'Lato';
	height: 40px;
  width: 220px;
	line-height: 40px;
	background-color: #428bca;
	color: #FFF;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 1px;
	border: none;
	text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
   margin: 0 auto;
   text-align: center;

}
.panel-title {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 16px;
    color: #ffffff;
}

.panel-heading {

    color: #428bca;
    background-color: #428bca;
    border-top: 1px solid #dddddd;
  	border-left: 1px solid #dddddd;
    border-right: 1px solid #dddddd;  
    //border-top-right-radius: 3px;
    //border-top-left-radius: 3px;
}

.panel-body {
    padding: 15px;
    border: 1px solid #dddddd;
}
.nobottommargin {
    margin-bottom: 0 !important;
}
.leftmargin-sm {
    margin-left: 30px !important;
}

.button.button-rounded {
	border-radius: 3px;
}

.button.button-reveal {
	padding: 0 28px;
	overflow: hidden;
}

.button.button-large {
	padding: 0 26px;
	font-size: 16px;
	height: 46px;
	line-height: 46px;
}

.button-teal {
	background-color: #428bca;
}

/*code for the icon */
.button-reveal i {
  position: absolute;
  width: 2em;
  height: 100%;
  line-height: 45px;
  background-color: rgba(0, 0, 0, .2);
  text-align: center;
  left: -100%;
  transition: left 0.25s ease;
}
.button-reveal:hover i {
  left: 0;
}
/* code for the letters*/
.button-reveal span {
  display: inline-block;
  margin: 0 2em;
  transition: margin 0.35s ease;
}
.button-reveal:hover span {
  margin: 0 1em 0 3em;
}
<div class="panel-heading">
								<h2 class="panel-title">Access This Service</h2>
							</div>

<div class="panel-body">
  <!-- angular -->
 		
  <div ng-if="c.html" ng-bind-html="c.html"></div>

 <a href="http://zoom.us" class="button button-rounded button-reveal button-large button-teal"><i class="fa fa-forward" aria-hidden="true"></i>
   <span>Go there now!</span></a><br>

Note: If you haven’t accessed Zoom before, create a new account at <a href="http://zoom.us">zoom.us</a>.
</div>

enter image description here

2 个答案:

答案 0 :(得分:2)

只需将min-width添加到按钮即可。

.button {
  display: inline-block;
  position: relative;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  //	margin: 5px;
  padding: 0 22px;
  font-size: 14px;
  font-family: 'Roboto', sans-serif, 'Lato';
  height: 40px;
  width: 220px;
  line-height: 40px;
  background-color: #428bca;
  color: #FFF;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
  margin: 0 auto;
  text-align: center;
}

.panel-title {
  margin-top: 0;
  margin-bottom: 0;
  font-size: 16px;
  color: #ffffff;
}

.panel-heading {
  color: #428bca;
  background-color: #428bca;
  border-top: 1px solid #dddddd;
  border-left: 1px solid #dddddd;
  border-right: 1px solid #dddddd;
  //border-top-right-radius: 3px;
  //border-top-left-radius: 3px;
}

.panel-body {
  padding: 15px;
  border: 1px solid #dddddd;
}

.nobottommargin {
  margin-bottom: 0 !important;
}

.leftmargin-sm {
  margin-left: 30px !important;
}

.button.button-rounded {
  border-radius: 3px;
}

.button.button-reveal {
  padding: 0 28px;
  overflow: hidden;
}

.button.button-large {
  padding: 0 26px;
  font-size: 16px;
  height: 46px;
  line-height: 46px;
}

.button-teal {
  background-color: #428bca;
}


/*code for the icon */

.button-reveal i {
  position: absolute;
  min-width: 2em;
  height: 100%;
  line-height: 45px;
  background-color: rgba(0, 0, 0, .2);
  text-align: center;
  left: -100%;
  transition: left 0.25s ease;
}

.button-reveal:hover i {
  left: 0;
}


/* code for the letters*/

.button-reveal span {
  display: inline-block;
  margin: 0 2em;
  transition: margin 0.35s ease;
}

.button-reveal:hover span {
  margin: 0 1em 0 3em;
}
<div class="panel-heading">
  <h2 class="panel-title">Access This Service</h2>
</div>

<div class="panel-body">
  <!-- angular -->

  <div ng-if="c.html" ng-bind-html="c.html"></div>

  <a href="http://zoom.us" class="button button-rounded button-reveal button-large button-teal"><i class="fa fa-forward" aria-hidden="true"></i>
   <span>Go there now!</span></a><br> Note: If you haven’t accessed Zoom before, create a new account at <a href="http://zoom.us">zoom.us</a>.
</div>

答案 1 :(得分:0)

当窗口调整大小低于某个宽度时,一种可能的途径是使用 @media query 来控制按钮填充和其他样式属性。

请考虑以下事项:

@media (max-width: 800px) {
  .button.test {
    padding: 0px;
  }
} 

这表示如果窗口低于800px设置padding 0的元素buttontest样式类。当窗口调整为宽度800px以上时,不会应用此选择器。

下面的代码段显示了一个带有和不带@media查询应用程序的按钮。我将查询放在样式表的末尾,因此填充不会被其他类覆盖。您也可以将它放在文件的顶部,但是需要注意,因此级联顺序不会覆盖您的样式。

查看内联片段,然后点击“整页”以查看第二个按钮上的填充更改。

.button {
  display: inline-block;
  position: relative;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  padding: 0 22px;
  font-size: 14px;
  font-family: 'Roboto', sans-serif, 'Lato';
  height: 40px;
  line-height: 40px;
  background-color: #428bca;
  color: #FFF;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
  margin: 0 auto;
  text-align: center;
}

.panel-heading {
  color: #428bca;
  background-color: #428bca;
  border-top: 1px solid #dddddd;
  border-left: 1px solid #dddddd;
  border-right: 1px solid #dddddd;
  //border-top-right-radius: 3px;
  //border-top-left-radius: 3px;
}

.panel-body {
  padding: 15px;
  border: 1px solid #dddddd;
}

.nobottommargin {
  margin-bottom: 0 !important;
}

.leftmargin-sm {
  margin-left: 30px !important;
}

.button.button-rounded {
  border-radius: 3px;
}

.button.button-reveal {
  padding: 0 28px;
  overflow: hidden;
}

.button.button-large {
  padding: 0 26px;
  font-size: 16px;
  height: 46px;
  line-height: 46px;
}

.button-teal {
  background-color: #428bca;
}


/*code for the icon */

.button-reveal i {
  position: absolute;
  width: 2em;
  height: 100%;
  line-height: 45px;
  background-color: rgba(0, 0, 0, .2);
  text-align: center;
  left: -100%;
  transition: left 0.25s ease;
}

.button-reveal:hover i {
  left: 0;
}


/* code for the letters*/

.button-reveal span {
  display: inline-block;
  margin: 0 2em;
  transition: margin 0.35s ease;
}

.button-reveal:hover span {
  margin: 0 1em 0 3em;
}

@media (max-width: 800px) {
  .button.test {
    padding: 0px !important;
  }
}
<div>Button NOT affected by @media</div>


<a href="http://zoom.us" class="button button-rounded button-reveal button-large button-teal"><i class="fa fa-forward" aria-hidden="true"></i>
   <span>Go there now!</span></a>

<div style="margin-top:20px;">Button affected by @media</div>

<a href="http://zoom.us" class="button test button-rounded button-reveal button-large button-teal"><i class="fa fa-forward" aria-hidden="true"></i>
   <span>Go there now!</span></a>

相关问题