Jquery UI 选项卡 - 更改选项卡的形状

标签 jquery css jquery-ui

您好,我正在考虑是否可以更改选项卡的形状,最好使用 Jquery UI。

我想要类似于下面标签的内容。

tabs[1]

或者有人可以建议我使用 css 实现此目的的任何方法吗?

最佳答案

我使用了一些 jquery 来切换选项卡,但选项卡样式完全是用 css 完成的,这就是您要找的东西吗?

下面的片段或这个jsfiddle

$('#tabwrapper ul li').on('click', function () {
	var divToShow = $(this).data('target');
  var root = $(this).closest('div');
  $('> div > div', root).hide();
  $('> div > div#' + divToShow, root).show();
});
html, body, div, ul {
  margin: 0;
  padding: 0;
}
ul {
  list-style-type: none;
  margin-top: -15px;
  margin-left: -1px;
}  
li {  
  float: left;  
  padding: 4px 15px 4px 30px;
	position: relative;
	background: #88b7d5;
	border: 1px solid #c2e1f5;
  cursor: pointer;
}
li + li {
  margin-left: 0;
}
li:after, li:before {
	left: 100%;
	top: 0%;
	border: solid transparent;
	content: " ";
	height: 0;
	width: 0;
	position: absolute;
	pointer-events: none;
  z-index: 1;
}
li:after {
	border-color: rgba(136, 183, 213, 0);
	border-left-color: #88b7d5;
	border-width: 13px;
	margin-top: 0px;  
}
li:before {
	border-color: rgba(194, 225, 245, 0);
	border-left-color: #c2e1f5;
	border-width: 14px;
	margin-top: -1px;
  z-index: 1;
}
li:hover {
  background-color: #444;
  color: #c2e1f5;
}
li:hover:after {
	border-color: rgba(136, 183, 213, 0);
	border-left-color: #444;
  }
#tabwrapper {  
  border: 1px solid #88b7d5;
  display: inline-block;
  padding-right: 12px;  
  margin-top: 20px;
  margin-left: 20px;
}
#tabwrapper > div {
  clear: both;
  padding: 10px 10px;
}
#tabwrapper > div > div {
  display: none;
  mine-height: 50px
}
#tabwrapper > div > div:first-child {
  display: block;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="tabwrapper">
<ul>
  <li data-target="tabcontent1">test1</li>
  <li data-target="tabcontent2">test2</li>
  <li data-target="tabcontent3">test3</li>
  <li data-target="tabcontent4">test4</li>
</ul>
<div style="clear: both;">
  <div id="tabcontent1">content1</div>
  <div id="tabcontent2">content2</div>
  <div id="tabcontent3">content3</div>
  <div id="tabcontent4">content4</div>
</div>
</div>

关于Jquery UI 选项卡 - 更改选项卡的形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42574399/

相关文章:

javascript - 在每个容器内移动 DOM 中的元素

javascript - 如何将价格限制为小数点后两位

javascript - 同一 Action 上的 2 个 jQuery 事件似乎相互抵消

html - 有无缝换行吗?

html - 如何对齐图标 Bootstrap 菜单(折叠状态)

javascript - 验证表单中的 jQuery-UI Spinner

jquery - 当边缘显示时停止拖动 jQuery

javascript - 通过 Google 跟踪代码管理器在 Universal Analytics 中使用多值自定义维度

html - 以中间一个为中心的三个 float div

jquery-ui - Emberjs 和 jQuery UI 克隆助手