首页 \ 问答 \ 斜杆上的Navbar(Navbar on Slanted Div)

斜杆上的Navbar(Navbar on Slanted Div)

我创建了一个与我的导航栏一起使用的预定div,但它会弄乱网站的其余格式。 导航栏位于右上方,倾斜的div位于其下方,但它会弄乱网页上的其他所有内容。 我一直在尝试一切无济于事。

http://imgur.com/a/bmv6l

导航HTML:

<template name="navbar">
  <div class="navbar">
    <ul>
      <li><a href="https://www.meteor.com/try">Contact</a></li>
      <li><a href="http://guide.meteor.com">Services</a></li>
      <li><a href="https://docs.meteor.com">Experience</a></li>
      <li><a href="https://forums.meteor.com" class="active">Home</a></li>
    </ul>
  </div>
</template>

Navbar CSS:

.navbar {
  position: relative;
  display: inline-block;
  padding: 0em 0em 1em 10em;
  overflow: hidden;
  color: #fff;
  float: right;
}

.navbar:after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000;
  -webkit-transform-origin: 100% 0;
  -ms-transform-origin: 100% 0;
  transform-origin: 100% 0;
  -webkit-transform: skew(45deg);
  -ms-transform: skew(45deg);
  transform: skew(45deg);
  z-index: -1;
}

ul {
  list-style-type: none;
  margin-left: 100px;
  margin: 0;
  padding: 0;
  padding-top: 1em;
  padding-right: 1em;
  padding-bottom: 5px;
  overflow: hidden;
  font-family: 'Open Sans', sans-serif;
  font-size: 20px;
  font-weight: bolder;
  -webkit-font-smoothing: antialiased;
  z-index: -1;
}

li {
  margin-left: 1em;
  margin-right: 2em;
  float: right;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 16px 16px;
  text-decoration: none;
  -webkit-box-shadow: 0px 0px 8px 0.5px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 0px 8px 0.5px rgba(0,0,0,0.75);
  box-shadow: 0px 0px 8px 0.5px rgba(0,0,0,0.75);
  border: 5px;
  border-style: solid;
  border-radius: 10px;
  border-color: white;
  transition: background 0.2s ease,
              padding 0.8s linear;
}

li a:hover {
  background-color: #111;
}

.active {
  border-radius: 8px;
  border-color: white;
  background-color: #555;
}

“山猫服务”Div HTML:

<body>
  <div id="nav">
    {{> navbar}}
  </div>
  <div id="center">
      <h1>Bobcats Services</h1>
      <h2>Everything you need!</h2>
  </div>
</body>

“山猫服务”Div CSS:

/* CSS declarations go here */
html {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;

  /*background-color: #0193ff;*/

  /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#00b7ea+0,009ec3+100;Blue+3D+%2315 */
  background: rgb(135,224,253); /* Old browsers */
  background: -moz-linear-gradient(top,  rgba(135,224,253,1) 0%, rgba(83,203,241,1) 40%, rgba(5,171,224,1) 100%); /* FF3.6-15 */
  background: -webkit-linear-gradient(top,  rgba(135,224,253,1) 0%,rgba(83,203,241,1) 40%,rgba(5,171,224,1) 100%); /* Chrome10-25,Safari5.1-6 */
  background: linear-gradient(to bottom,  rgba(135,224,253,1) 0%,rgba(83,203,241,1) 40%,rgba(5,171,224,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#87e0fd', endColorstr='#05abe0',GradientType=0 ); /* IE6-9 */

  /* Image instead of standard color
  background-image: url("images/watch-plane.png");
  background-repeat: no-repeat;
  background-size: cover;
  */
}

#nav {

}

#center {
  width: 30%;
  padding-bottom: 2em;
  padding-top: 2em;
  margin: auto;
  margin-top: 2em;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border-style: solid;
  border-radius: 5px;
  border-color: #008fc8;
  font-family: 'Open Sans', sans-serif;
}

I have created a slated div to use with my navbar, but it messes up the rest of the formatting for the website. The navbar is in the top right and the slanted div is underneath it, but it messes up everything else on the webpage. I've been trying everything to no avail.

http://imgur.com/a/bmv6l

Navbar HTML:

<template name="navbar">
  <div class="navbar">
    <ul>
      <li><a href="https://www.meteor.com/try">Contact</a></li>
      <li><a href="http://guide.meteor.com">Services</a></li>
      <li><a href="https://docs.meteor.com">Experience</a></li>
      <li><a href="https://forums.meteor.com" class="active">Home</a></li>
    </ul>
  </div>
</template>

Navbar CSS:

.navbar {
  position: relative;
  display: inline-block;
  padding: 0em 0em 1em 10em;
  overflow: hidden;
  color: #fff;
  float: right;
}

.navbar:after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000;
  -webkit-transform-origin: 100% 0;
  -ms-transform-origin: 100% 0;
  transform-origin: 100% 0;
  -webkit-transform: skew(45deg);
  -ms-transform: skew(45deg);
  transform: skew(45deg);
  z-index: -1;
}

ul {
  list-style-type: none;
  margin-left: 100px;
  margin: 0;
  padding: 0;
  padding-top: 1em;
  padding-right: 1em;
  padding-bottom: 5px;
  overflow: hidden;
  font-family: 'Open Sans', sans-serif;
  font-size: 20px;
  font-weight: bolder;
  -webkit-font-smoothing: antialiased;
  z-index: -1;
}

li {
  margin-left: 1em;
  margin-right: 2em;
  float: right;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 16px 16px;
  text-decoration: none;
  -webkit-box-shadow: 0px 0px 8px 0.5px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 0px 8px 0.5px rgba(0,0,0,0.75);
  box-shadow: 0px 0px 8px 0.5px rgba(0,0,0,0.75);
  border: 5px;
  border-style: solid;
  border-radius: 10px;
  border-color: white;
  transition: background 0.2s ease,
              padding 0.8s linear;
}

li a:hover {
  background-color: #111;
}

.active {
  border-radius: 8px;
  border-color: white;
  background-color: #555;
}

"Bobcats Services" Div HTML:

<body>
  <div id="nav">
    {{> navbar}}
  </div>
  <div id="center">
      <h1>Bobcats Services</h1>
      <h2>Everything you need!</h2>
  </div>
</body>

"Bobcats Services" Div CSS:

/* CSS declarations go here */
html {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;

  /*background-color: #0193ff;*/

  /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#00b7ea+0,009ec3+100;Blue+3D+%2315 */
  background: rgb(135,224,253); /* Old browsers */
  background: -moz-linear-gradient(top,  rgba(135,224,253,1) 0%, rgba(83,203,241,1) 40%, rgba(5,171,224,1) 100%); /* FF3.6-15 */
  background: -webkit-linear-gradient(top,  rgba(135,224,253,1) 0%,rgba(83,203,241,1) 40%,rgba(5,171,224,1) 100%); /* Chrome10-25,Safari5.1-6 */
  background: linear-gradient(to bottom,  rgba(135,224,253,1) 0%,rgba(83,203,241,1) 40%,rgba(5,171,224,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#87e0fd', endColorstr='#05abe0',GradientType=0 ); /* IE6-9 */

  /* Image instead of standard color
  background-image: url("images/watch-plane.png");
  background-repeat: no-repeat;
  background-size: cover;
  */
}

#nav {

}

#center {
  width: 30%;
  padding-bottom: 2em;
  padding-top: 2em;
  margin: auto;
  margin-top: 2em;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border-style: solid;
  border-radius: 5px;
  border-color: #008fc8;
  font-family: 'Open Sans', sans-serif;
}

原文:https://stackoverflow.com/questions/38650894
更新时间:2023-04-06 21:04

最满意答案

IIUIC,这是一种方法。 比方说,

直径终点之间的gapgap ,(红线的长度)

base是当前圈的左径点

base + d给你当前圈的中心

newbase是下一圈的左侧直径点

var myData1 = [5, 10, 15]
var mySvg1 = d3.select('body').append('svg')

var base = 90
var newbase = 90
var gap = 20
mySvg1.selectAll('circle').data(myData1).enter().append('circle')
    .attr('cx', function(d, i){
      base = newbase
    	newbase = newbase + 2*d + gap
    	return base + d
      })
    .attr('cy', '55')
    .attr('r', function(d){return d})
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>

https://jsfiddle.net/utfk44tL/


IIUIC, Here's one way. Let's say,

Gap between diameter endpoints is gap, (length of red lines)

base is current circle's left diameter point

base + d gives you current circle's center

newbase is next circle's left diameter point

var myData1 = [5, 10, 15]
var mySvg1 = d3.select('body').append('svg')

var base = 90
var newbase = 90
var gap = 20
mySvg1.selectAll('circle').data(myData1).enter().append('circle')
    .attr('cx', function(d, i){
      base = newbase
    	newbase = newbase + 2*d + gap
    	return base + d
      })
    .attr('cy', '55')
    .attr('r', function(d){return d})
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>

https://jsfiddle.net/utfk44tL/

相关问答

更多
  • 如果要使用圆半径和间距定义,则计算列中第i个圆的y坐标的公式可以是这样的: Yith = Y+[i-(n+1)/2]*(diameter+padding) 其中Y是第一个(蓝色)圆的y坐标, i是列中的第i个圆, n表示列中的圆数, (直径+填充)显示在图像上。 它代表球的直径与间距。 The formula for calculating y-coordinate for ith circle in the column could be like this if you would like to d ...
  • 您的代码非常接近正确: 工作演示 。 使用比例来映射对象的位置 除了保存对象的确切位置,然后使用range和domain设置为[0, 1]的缩放比例,请使用比例为您执行映射: for (j = _i = 0; _i <= 6; j = ++_i) { for (i = _j = 0; _j <= 12; i = ++_j) { circles.push({ r: 25, cx: i, cy: j, color: "#000" }); } ...
  • IIUIC,这是一种方法。 比方说, 直径终点之间的gap是gap ,(红线的长度) base是当前圈的左径点 base + d给你当前圈的中心 newbase是下一圈的左侧直径点 var myData1 = [5, 10, 15] var mySvg1 = d3.select('body').append('svg') var base = 90 var newbase = 90 var gap = 20 mySvg1.selectAll('circle').data(myData1).en ...
  • 解决方案演示: 注意缺乏对称性: http://jsfiddle.net/blakedietz/R5cRK/1/embedded/result/ 做法: 确定一个能正确模拟你想要的运动的数学函数。 在这种情况下,我们需要一个正弦波 。 我们可以修改每个气泡特征的各个方面,为每个气泡提供独特的运动模式。 建立或找到一个解决方案,利用这个问题所需的关键概念。 我喜欢在bl.ocks.org/mbostock上搜索具有我试图解决的问题的基础部分的示例。 在网站上我找到了这个例子: http : //bl.ocks ...
  • 您应该按降序对padeedits字段对接收到的数据进行排序,因此较小的圆圈会在较小的圆圈之前插入,并且不会有任何重叠。 所以以这种方式修改你的代码: ... svg.selectAll(".loading").remove(); // code block for inserting data.sort(function(a,b) { if (a.pageedits > b.pageedits) return -1; if (a.pageedits < b.p ...
  • 只要问你是否需要解释我会尽我所能,但现在不是这次我必须回家 就像我在d3上的每个图表之前所说的那样,在制作它之前先了解结构,了解这个结构图,如果你看到工作中的数据数组,你会看到没有子对象和2个数组之间的id或源有相同的值。 我假设您的数据在2数据数组,ID和源之间没有相同的数据值,这就是您拥有的原因 错误:遗失:哺乳动物 我将缺少的mamal添加到children对象中 如果您控制节点和链接,您会发现此图表类型生成vx和vy TypeError:无法在字符串'mammal'上创建属性'vx' 是一个链误差因 ...
  • 代码中的基本问题是您同时为所有点应用相同的翻译。 实际上你的所有圈子都沿着路径移动,但它们互相覆盖 - 所以你已经完成了任务的主要部分。 但是,如果您希望不同的圆圈位于不同的坐标处,则必须为它们应用不同的补间。 也就是说,即使你为每个圆计算出startPoints是不同的,你也不要在动画中使用它,所以所有的圆都在一起移动。 我通过将点的索引作为新参数添加到translateAlong函数,并使用一些基本数学计算圆的位置来解决这个问题,因此它变为: function translateAlong(path,i ...
  • 首先,您可以将数据简化为: .data(d3.range(100)); 要使用矩形制作矩阵,您可以使用: .attr("x", (d,i) => i%10 * 45) .attr("y", (d,i) => Math.floor(i/10)%10 * 45) 这是一个演示: var ContainerWidth = document.querySelector('#mainContainer').offsetWidth; var rectWidth = ContainerWidth / 20; ...
  • 您在HTML中附加了元素,而不是SVG。 它没有任何意义,所以它不会被渲染。 您需要附加一个svg元素,然后将您的圆和文本节点附加到该元素。 填充,描边宽度和笔划也应该使用.style而不是.attr 。 一些相关的代码更改是: var svg = d3.select('.circles').append('svg') // added .append('svg') .attr('height', /* set the height */) .attr('width', /* ...
  • 在你的代码中没有工作的第一件事是你没有创建一个svg元素,你将在其中绘制你的圆圈。 所以你必须更换 var nodesG = d3.selectAll("g"); 通过 var nodesG = d3.select('body').append('svg'); 然后,您没有很好地定义圆圈的属性x和y。 我想这些属性取决于每个节点的属性x和y 。 因此,您必须替换以下内容: .attr("cx", x) .attr("cy", y) 通过: .at ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)